]> Sergey Matveev's repositories - public-inbox.git/blob - examples/cgi-webrick.rb
add example for CGI with Ruby WEBrick
[public-inbox.git] / examples / cgi-webrick.rb
1 #!/usr/bin/env ruby
2 require 'webrick'
3 require 'logger'
4 options = {
5   :BindAddress => '127.0.0.1',
6   :Port => 8080,
7   :Logger => Logger.new($stderr),
8   :AccessLog => [
9     [ Logger.new($stdout), WEBrick::AccessLog::COMBINED_LOG_FORMAT ]
10   ],
11 }
12 server = WEBrick::HTTPServer.new(options)
13 server.mount("/",
14              WEBrick::HTTPServlet::CGIHandler,
15             "#{Dir.pwd}/blib/script/public-inbox.cgi")
16 ['INT', 'TERM'].each do |signal|
17   trap(signal) {exit}
18 end
19 server.start