not using offline mode in webrick

Discussion in 'Ruby' started by Max Benjamin, Mar 26, 2007.

  1. Max Benjamin

    Max Benjamin Guest

    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-forum.com/.
     
    Max Benjamin, Mar 26, 2007
    #1
    1. Advertising

  2. Max Benjamin

    Eric Hodel Guest

    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.
     
    Eric Hodel, Mar 28, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John J Lee
    Replies:
    3
    Views:
    507
    bruno at modulix
    Dec 1, 2005
  2. Edward Loper
    Replies:
    0
    Views:
    491
    Edward Loper
    Aug 7, 2007
  3. John J Lee
    Replies:
    0
    Views:
    537
    John J Lee
    Aug 7, 2007
  4. Lloyd Zusman
    Replies:
    2
    Views:
    415
  5. Aaron Smith

    WEBrick::Daemon and WEBrick

    Aaron Smith, Mar 9, 2007, in forum: Ruby
    Replies:
    2
    Views:
    324
    Aaron Smith
    Mar 18, 2007
Loading...

Share This Page