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 = HTTPServer.new(
:Port => 3000,
:DocumentRoot => Dir::pwd
)
trap("INT"){ s.shutdown }
s.start