From: zerohalo Date: 2006-09-21T02:35:15+09:00 Subject: Re: super simple serving of ruby pages Thanks, Jan. That was easy. Now .rhtml files render correctly. Is there a way to tell it to execute .rb files rather than treat them as simple text files? Jan Svitok wrote: > On 9/20/06, zerohalo wrote: > > Yes, I tried that. Unfortunately there is no documentation on the > > webrick site on how to use ERBHandler. I have this in a ruby script > > which does start up the Webrick server. However, while it serves HTML > > files fine, it treats RHTML files as binaries and RB files as just > > plain text. Here's my code: > > 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('/data/sandbox/ruby') > - server.mount("/data/sandbox/ruby", HTTPServlet::ERBHandler, ruby_dir) > server.start > end > > start_webrick(:DocumentRoot => '/data/sandbox/ruby')