From: "Ara.T.Howard" Date: 2003-10-04T09:52:45+09:00 Subject: Re: CGI and Webrick On Sat, 4 Oct 2003, Ben Giddings wrote: > Hey all, > > I've just started poking at three Ruby tools I haven't yet used: DBI, > Webrick, and CGI, and have a few questions: > > * Is there good documentation for these somewhere? The distribution site > for DBI has one page listing methods for some of the objects, but not > others. For example, DBI::Row doesn't seem to be documented at all. > Webrick seems about the same, there are some quick examples, but no API > documentation I could find. > > * Is there a way to get CGI to simply generate HTML? I managed to get it > to stop prompting me to set variables using: > > echo | ruby my_cgi_using_prog.rb even better (if you want to test input parameters) is ~ > cat input key=value a=b ruby my_cgi_using_prog.rb < input if no values ruby my_cgi_using_prog.rb < /dev/null if you want to generate html - check out amrita or misen. eg. ----CUT---- #!/usr/bin/env ruby require 'amrita/template' template = Amrita::TemplateText.new <<-html
html data = Hash[ :rows => [ {:name => 'joe', :ssn => '574-86-5022'}, {:name => 'jane', :ssn => '574-86-5021'}, ] ] template.expand STDOUT, data __END__ OUTPUT:
joe574-86-5022
jane574-86-5021
----CUT---- it's powerfull. -a > > But then it throws on content-type headers, which I don't want in my output. > > * Does anybody have experience connecting Webrick and CGI? Any tips, pointers? > > Ben > > > ==================================== | Ara Howard | NOAA Forecast Systems Laboratory | Information and Technology Services | Data Systems Group | R/FST 325 Broadway | Boulder, CO 80305-3328 | Email: ara.t.howard@noaa.gov | Phone: 303-497-7238 | Fax: 303-497-7259 | The difference between art and science is that science is what we understand | well enough to explain to a computer. Art is everything else. | -- Donald Knuth, "Discover" | ~ > /bin/sh -c 'for lang in ruby perl; do $lang -e "print \"\x3a\x2d\x29\x0a\""; done' ====================================