Created
February 8, 2012 11:24
-
-
Save toto/1768284 to your computer and use it in GitHub Desktop.
A simple webserver that makes the current directory available via HTTP
This file contains hidden or 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" | |
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