Problem with WEBRick and eruby

V

vendemotos

Hi,

I am just starting in both ruby and web development so maybe the
following pieces of code seem a sin for most of you.

I am writing a HTML form in a rhtml file and pass the parameters to
antoher rhtml with embebed ruby.

The HTTP server is built as follows:

-----------------

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('/www')
server.mount("/www", HTTPServlet::ERBHandler, ruby_dir)
server.start
end

start_webrick:)DocumentRoot => '/www')

-----------

the index.htrml is like follows

-----------

<HTML>
<FORM action="response.rhtml" method="POST">
METAR: <INPUT type="text" name="metar" size=80><BR>
<INPUT type="submit" value="Process">
</FORM>
</HTML>

----------


And finally the response.rhtml is

--------
<HTML>
<%
require 'cgi'

cgi = CGI.new

#Rest of code
%>
</HTML>
--------

The webrick server shows the following info while the loading of
response.rhtml simply freezes

----------
[2007-02-03 09:48:15] INFO WEBrick 1.3.1
[2007-02-03 09:48:15] INFO ruby 1.8.5 (2006-08-25) [i386-mswin32]
[2007-02-03 09:48:15] INFO WEBrick::HTTPServer#start: pid=1372
port=8080
nicalejo - - [03/Feb/2007:09:48:29 Romance Standard Time] "GET / HTTP/
1.1" 200 1
93
- -> /
[2007-02-03 09:48:43] ERROR `/response.rhtml' not found.
nicalejo - - [03/Feb/2007:09:48:43 Romance Standard Time] "POST /
response.rhtml
HTTP/1.1" 404 284
http://localhost:8080 -> /response.rhtml
(offline mode: enter name=value pairs on standard input)
 
J

Jan Svitok

Hi,

I am just starting in both ruby and web development so maybe the
following pieces of code seem a sin for most of you.

I am writing a HTML form in a rhtml file and pass the parameters to
antoher rhtml with embebed ruby.

The HTTP server is built as follows:

-----------------

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('/www')
server.mount("/www", HTTPServlet::ERBHandler, ruby_dir)
server.start
end

start_webrick:)DocumentRoot => '/www')

-----------

the index.htrml is like follows

-----------

<HTML>
<FORM action="response.rhtml" method="POST">
METAR: <INPUT type="text" name="metar" size=80><BR>
<INPUT type="submit" value="Process">
</FORM>
</HTML>

----------


And finally the response.rhtml is

--------
<HTML>
<%
require 'cgi'

cgi = CGI.new

#Rest of code
%>
</HTML>
--------

The webrick server shows the following info while the loading of
response.rhtml simply freezes

----------
[2007-02-03 09:48:15] INFO WEBrick 1.3.1
[2007-02-03 09:48:15] INFO ruby 1.8.5 (2006-08-25) [i386-mswin32]
[2007-02-03 09:48:15] INFO WEBrick::HTTPServer#start: pid=1372
port=8080
nicalejo - - [03/Feb/2007:09:48:29 Romance Standard Time] "GET / HTTP/
1.1" 200 1
93
- -> /
[2007-02-03 09:48:43] ERROR `/response.rhtml' not found.
nicalejo - - [03/Feb/2007:09:48:43 Romance Standard Time] "POST /
response.rhtml
HTTP/1.1" 404 284
http://localhost:8080 -> /response.rhtml
(offline mode: enter name=value pairs on standard input)
-----------

Why this offline message? Any suggestion?

Thanks in advance to the rubyists

Hi,
CGI expects data on stdin (see the message). The problem is that
webrick doesn't pass it to ERB pages as such. Look at ERB handler how
the vars are actually sent (I suppose there would be some @request or
similar).
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,152
Members
46,697
Latest member
AugustNabo

Latest Threads

Top