Skip to content

Instantly share code, notes, and snippets.

@dnshl
Created July 18, 2012 18:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dnshl/3137951 to your computer and use it in GitHub Desktop.
Save dnshl/3137951 to your computer and use it in GitHub Desktop.
Ruby HTTP Server for local Dir
require 'webrick'
def serve
dir = Dir::pwd
port = 12000 + (dir.hash % 1000)
s = WEBrick::HTTPServer.new(
:Port => port,
:DocumentRoot => dir
)
trap("INT") { s.shutdown }
s.start
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment