Skip to content

Instantly share code, notes, and snippets.

@schmidt
Created October 13, 2008 13:37
Show Gist options
  • Save schmidt/16537 to your computer and use it in GitHub Desktop.
Save schmidt/16537 to your computer and use it in GitHub Desktop.
Instant webserver for current dir. Fetches free port automatically.
#!/usr/bin/env ruby
require 'webrick'
port = 3000
begin
s = WEBrick::HTTPServer.new(
:Port => port,
:DocumentRoot => Dir::pwd
)
port += 1
end while s.listeners.size < 2
trap("INT") { s.shutdown }
s.start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment