Index: [Article Count Order] [Thread]

Date: Sat, 6 Sep 2003 17:01:27 -0400
From: Mark Wilson <mwilson13@cox.net>
Subject: [webricken:121] Getting .shtml to work
To: webricken@notwork.org
Message-Id: <47EB7DAC-E0AD-11D7-8F3D-000393876156@cox.net>
In-Reply-To: <20030902.190148.629461786.gotoyuzo@kotetsu.does.notwork.org>
X-Mail-Count: 00121

Hi Webrickians!

Thank you for the help on my previous question. I'm now trying to get 
.shtml files to work. The example below ('current-time.shtml' and 
'print-time.rb') is taken from Chapter 20 of Mark Slagell's Teach 
Yourself Ruby book.

I assume there is an expression to 'register' how Webrick handles 
.shtml files, but I don't know how to do it.

I'm trying to get .shtml to work using the following:

1. 'current-time.shtml'
------------------------
<html><body>
Date: <b><!--#exec cmd="./print-time.rb" --></b><br>
</body></html>
------------------------

2. 'print-time.rb'
------------------------
#!/usr/local/bin/ruby

puts Time.now
------------------------

3. 'webricktest.rb'
------------------------
#!/usr/local/bin/ruby
require 'webrick'
include WEBrick
docroot = File::join(Dir::pwd, "htdocs")
cgibin = File::join(docroot, "cgi-bin")
s = HTTPServer.new(
                    :Port => 2000,
                    :DocumentRoot => docroot
)
file_handler_opt = { :HandlerTable => Hash.new(HTTPServlet::CGIHandler) 
}
s.mount("/cgi-bin", HTTPServlet::FileHandler, cgibin, file_handler_opt)
trap("INT") { s.shutdown }
s.start
------------------------

4. Relevant directory listings
------------------------
For webrick server:
drwxr-xr-x    5 markwils wheel         170 Sep  6 15:27 ./
drwxr-xr-x  107 markwils wheel        3638 Sep  6 16:35 ../
drwxr-x---   12 markwils wheel         408 Sep  6 16:40 htdocs/
-rwxr--r--    1 markwils wheel         417 Sep  6 15:27 webricktest.rb*

For htdocs:
drwxr-x---   12 markwils wheel         408 Sep  6 16:40 ./
drwxr-xr-x    5 markwils wheel         170 Sep  6 15:27 ../
drwxr-xr-x   13 markwils wheel         442 Sep  4 16:27 cgi-bin/
-rw-r--r--    1 markwils wheel          81 Sep  6 16:40 
current-time.shtml
-rwxr--r--    1 markwils wheel          30 Sep  2 17:46 print-time.rb*
------------------------

5. Browser output for 'current-time.shtml'
------------------------
<html><body>
Date: <b><!--#exec cmd="./print-time.rb" --></b><br>
</body></html>
------------------------

6. Webrick console output
------------------------
localhost - - [06/Sep/2003:16:40:19 EDT] "GET /current-time.shtml 
HTTP/1.1" 200 81
http://localhost:2000/ -> /current-time.shtml
------------------------

Any help would be greatly appreciated.

Regards,

Mark