Skip to content

Instantly share code, notes, and snippets.

@toto
Created February 8, 2012 11:24
Show Gist options
  • Save toto/1768284 to your computer and use it in GitHub Desktop.
Save toto/1768284 to your computer and use it in GitHub Desktop.
A simple webserver that makes the current directory available via HTTP
#!/usr/bin/env ruby
require "webrick"
port = ARGV.count > 0 ? ARGV.last.to_i : 8080
STDERR.puts "Starting WEBRick server on http://localhost:#{port}"
server = WEBrick::HTTPServer.new :Port => port
server.mount "/", WEBrick::HTTPServlet::FileHandler, './'
trap('INT') do
STDERR.puts "Stopping WEBRick"
server.stop
end
server.start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment