about summary refs log tree commit homepage
path: root/examples/cgi-webrick.rb
blob: 1bc690f1fbb7f7f7a6225ccb6fa02f502d4c550e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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