]> Sergey Matveev's repositories - public-inbox.git/commitdiff
add example for CGI with Ruby WEBrick
authorEric Wong <e@80x24.org>
Thu, 17 Apr 2014 21:56:12 +0000 (21:56 +0000)
committerEric Wong <e@80x24.org>
Thu, 17 Apr 2014 21:57:15 +0000 (21:57 +0000)
Some people like old-fashioned Ruby and WEBrick is in the Ruby
standard library, so widely available.

examples/cgi-webrick.rb [new file with mode: 0644]

diff --git a/examples/cgi-webrick.rb b/examples/cgi-webrick.rb
new file mode 100644 (file)
index 0000000..1bc690f
--- /dev/null
@@ -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