Sometimes I find myself in need of a quick and dirty HTTP server when I'm working in plain HTML with a little Javascript. For example: when I'm building banner ads that use scriptaculous. Rather than mess with lighttpd and get the files where it can see them, I found myself wanting to the do the old "ruby script/server" as we do in Rails.

So I looked at the Webrick home page, and ended up with this:

    require 'webrick'
    include WEBrick
    s =
     :Port => 3000,
     :DocumentRoot => Dir::pwd
    trap("INT"){ s.shutdown }
I named it server.rb and just drop it in the directory containing the html files I want to test. A simple "ruby server.rb" fires it up and then I can then use a URL like: to see my files. Now when I'm developing on my Linux box, I can use IE on a separate (WinXP) box to quickly test what I've done. No need to add symlinks or otherwise wire things up such that lighty can see my work.

There are two problems with this, 1. I could not get eRuby (.rhtml) to work with Webrick and 2. it is dreadfully slow. So for testing eRuby stuff, I'm still using lighty.