about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2014-04-17 21:56:12 +0000
committerEric Wong <e@80x24.org>2014-04-17 21:57:15 +0000
commitae1c27f9ff9b38ba038b7cc6a19e1d9bc2cee714 (patch)
treec50e4d9b9bb8f522fdd315e9044881511f8acfce
parentb926665849f6d317b97cf679becf1e315df701b0 (diff)
downloadpublic-inbox-ae1c27f9ff9b38ba038b7cc6a19e1d9bc2cee714.tar.gz
Some people like old-fashioned Ruby and WEBrick is in the Ruby
standard library, so widely available.
-rw-r--r--examples/cgi-webrick.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/examples/cgi-webrick.rb b/examples/cgi-webrick.rb
new file mode 100644
index 00000000..1bc690f1
--- /dev/null
+++ b/examples/cgi-webrick.rb
@@ -0,0 +1,19 @@
+#!/usr/bin/env ruby
+require 'webrick'
+require 'logger'
+options = {
+  :BindAddress => '127.0.0.1',
+  :Port => 8080,
+  :Logger => Logger.new($stderr),
+  :AccessLog => [
+    [ Logger.new($stdout), WEBrick::AccessLog::COMBINED_LOG_FORMAT ]
+  ],
+}
+server = WEBrick::HTTPServer.new(options)
+server.mount("/",
+             WEBrick::HTTPServlet::CGIHandler,
+            "#{Dir.pwd}/blib/script/public-inbox.cgi")
+['INT', 'TERM'].each do |signal|
+  trap(signal) {exit}
+end
+server.start