From: anne001 Date: 2006-06-20T21:53:47+09:00 Subject: wish list: webrick server with cgi test file Anyone has a webrick server which works with a cgi test file, to share with me? Hopefully, not all webrick users are at the rails conference! I have tried various combinations with various errors. Here is the latest attempt using the info on this page for server and test file http://microjet.ath.cx/webrickguide/html/CGIHandler.html -----------------> require 'webrick' include WEBrick # let's import the namespace so # I don't have to keep typing # WEBrick:: in this documentation. def start_webrick(config = {}) # always listen on port 8080 config.update(:Port => 8080) server = HTTPServer.new(config) yield server if block_given? ['INT', 'TERM'].each {|signal| trap(signal) {server.shutdown} } server.start end start_webrick {|server| cgi_dir = '/library/webserver/documents/ruby/cgi-bin' server.mount('/cgi-bin', HTTPServlet::FileHandler, cgi_dir, {:FancyIndexing=>true}) } with the test file in cgi-bin, test2.cgi, executable #!/usr/bin/env ruby print "Content-type: text/plain\r\n\r\n" ENV.keys.sort.each{|k| puts "#{k} ==> #{ENV[k]}"} I get an error message. env: ruby: No such file or directory With other attempts I get other errors. I started with the webserver on this page http://microjet.ath.cx/webrickguide/html/What_is_WEBrick.html ----------------> require 'webrick' include WEBrick # let's import the namespace so # I don't have to keep typing # WEBrick:: in this documentation. def start_webrick(config = {}) # always listen on port 8080 config.update(:Port => 8080) server = HTTPServer.new(config) yield server if block_given? ['INT', 'TERM'].each {|signal| trap(signal) {server.shutdown} } server.start end start_webrick(:DocumentRoot => '/library/webserver/documents/ruby/cgi-bin') ---------------------- it serves a hello.html file in cgi-bin directory fine. -----------------> A Small Hello

Hi

This is very minimal "hello world" HTML document.