A
abc-
Hi,
i'm new to ruby and tried some code to get a small application.
I used Webrick to get a http server:
require 'webrick'
include WEBrick
s = HTTPServer.newPort => 8000)
# Add a mime type for *.rhtml files
HTTPUtils:efaultMimeTypes.store('rhtml', 'text/html')
# Required for CGI on Windows; unnecessary on Unix/Linux
s.config.store( :CGIInterpreter, "#{HTTPServlet::CGIHandler::Ruby}")
# Mount servlets
s.mount('/test', HTTPServlet::FileHandler, '/')
# Trap signals so as to shutdown cleanly.
['TERM', 'INT'].each do |signal|
trap(signal){ s.shutdown }
end
# Start the server and block on input.
s.start
and i created an rhtml file:
<html>
<head>
<title>Ruby Test</title>
</head>
<body>
<h2>Test</h2>
<form>
<% require 'mysql' %>
<% my = Mysql::new("localhost", "root", "", "books_development") %>
<% res = my.query("select ID,Name from books Limit 10") %>
<table>
<% res.each { |i| puts "<tr><td> #{i} </td></tr>" } %>
</table>
</form>
</body>
</html>
Now the problem is that i can see the html in my browser but the result of embedded Ruby code only in my Konsole. Could anyone give me the right direction.
Thanks in advance
dirk
--------------= Posted using GrabIt =----------------
------= Binary Usenet downloading made easy =---------
-= Get GrabIt for free from http://www.shemes.com/ =-
i'm new to ruby and tried some code to get a small application.
I used Webrick to get a http server:
require 'webrick'
include WEBrick
s = HTTPServer.newPort => 8000)
# Add a mime type for *.rhtml files
HTTPUtils:efaultMimeTypes.store('rhtml', 'text/html')
# Required for CGI on Windows; unnecessary on Unix/Linux
s.config.store( :CGIInterpreter, "#{HTTPServlet::CGIHandler::Ruby}")
# Mount servlets
s.mount('/test', HTTPServlet::FileHandler, '/')
# Trap signals so as to shutdown cleanly.
['TERM', 'INT'].each do |signal|
trap(signal){ s.shutdown }
end
# Start the server and block on input.
s.start
and i created an rhtml file:
<html>
<head>
<title>Ruby Test</title>
</head>
<body>
<h2>Test</h2>
<form>
<% require 'mysql' %>
<% my = Mysql::new("localhost", "root", "", "books_development") %>
<% res = my.query("select ID,Name from books Limit 10") %>
<table>
<% res.each { |i| puts "<tr><td> #{i} </td></tr>" } %>
</table>
</form>
</body>
</html>
Now the problem is that i can see the html in my browser but the result of embedded Ruby code only in my Konsole. Could anyone give me the right direction.
Thanks in advance
dirk
--------------= Posted using GrabIt =----------------
------= Binary Usenet downloading made easy =---------
-= Get GrabIt for free from http://www.shemes.com/ =-