Skip to content

Instantly share code, notes, and snippets.

@quirkey
Created October 15, 2011 03:32
Show Gist options
  • Save quirkey/1288986 to your computer and use it in GitHub Desktop.
Save quirkey/1288986 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'webrick'
include WEBrick
dir = Dir::pwd
port = (ARGV.first || (12000 + (dir.hash % 1000))).to_i
url = "http://#{Socket.gethostname}:#{port}"
puts "Opening #{url}"
`open #{url}`
s = HTTPServer.new(
:Port => port,
:DocumentRoot => dir
)
trap("INT"){ s.shutdown }
s.start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment