require "webrick" WEBrick::HTTPServlet::FileHandler.add_handler("rb", WEBrick::HTTPServlet::CGIHandler) httpd = WEBrick::HTTPServer.new( :DocumentRoot => File::dirname('./'), :Port => 9999, :Logger => WEBrick::Log.new($stderr, WEBrick::Log::DEBUG), :DirectoryIndex => ['index.rb'], :DirectoryListEnable => false, :CGIPathEnv => ENV["PATH"] # PATH environment variable for CGI. ) trap(:INT){ httpd.shutdown } httpd.start