From ae1c27f9ff9b38ba038b7cc6a19e1d9bc2cee714 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 17 Apr 2014 21:56:12 +0000 Subject: add example for CGI with Ruby WEBrick Some people like old-fashioned Ruby and WEBrick is in the Ruby standard library, so widely available. --- examples/cgi-webrick.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 examples/cgi-webrick.rb (limited to 'examples/cgi-webrick.rb') 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 -- cgit v1.2.3-24-ge0c7