Created
December 12, 2013 20:49
-
-
Save jtzemp/7935186 to your computer and use it in GitHub Desktop.
http://onestepback.org/index.cgi/Tech/Ruby/WEBrick.rdoc with a change to use /usr/bin/env ruby instead of /usr/local/bin/ruby
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'webrick' | |
include WEBrick | |
dir = Dir::pwd | |
port = 12000 + (dir.hash % 1000) | |
url = "http://#{Socket.gethostname}:#{port}" | |
puts "URL: #{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