[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

not using offline mode in webrick

Max Benjamin

3/26/2007 6:37:00 PM

Hello list,
I'm using webrick to serve up rhtml pages and can't seem to access cgi
variables. My very very simple server looks like this:
########################
require 'webrick'
include WEBrick

def start_webrick(config = {})
config.update(:Port => 8080)
config.update(:MimeTypes => {'rhtml' => 'text/html'})
server = HTTPServer.new(config)
yield server if block_given?
['INT', 'TERM'].each {|signal|
trap(signal) {server.shutdown}
}
ruby_dir = File.expand_path('html')
server.mount("html", HTTPServlet::ERBHandler, ruby_dir)
server.start
end

start_webrick(:DocumentRoot => 'html')
#########################

When I attempt to get cgi variables I receive the following message:
(offline mode: enter name=value pairs on standard input)

How do I run the program in "non-offline" mode?

Thanks for the help!

--
Posted via http://www.ruby-....

1 Answer

Eric Hodel

3/28/2007 2:51:00 AM

0

On Mar 26, 2007, at 11:37, Max Benjamin wrote:

> Hello list,
> I'm using webrick to serve up rhtml pages and can't seem to access cgi
> variables. My very very simple server looks like this:
> ########################
> require 'webrick'
> include WEBrick
>
> def start_webrick(config = {})
> config.update(:Port => 8080)
> config.update(:MimeTypes => {'rhtml' => 'text/html'})
> server = HTTPServer.new(config)
> yield server if block_given?
> ['INT', 'TERM'].each {|signal|
> trap(signal) {server.shutdown}
> }
> ruby_dir = File.expand_path('html')
> server.mount("html", HTTPServlet::ERBHandler, ruby_dir)
> server.start
> end
>
> start_webrick(:DocumentRoot => 'html')
> #########################
>
> When I attempt to get cgi variables I receive the following message:
> (offline mode: enter name=value pairs on standard input)
>
> How do I run the program in "non-offline" mode?

Don't use CGI variables, use objects handed to the ERb page by
WEBrick. I think they're in meta_vars and query.