Created
June 16, 2009 00:33
-
-
Save sousk/130450 to your computer and use it in GitHub Desktop.
weby: make current directory accessible via HTTP
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' | |
require 'optparse' | |
include WEBrick | |
OPTIONS = { | |
# :BindingAddress => '0.0.0.0', | |
:Port => 3000, | |
:Charset => 'UTF-8', | |
:DocumentRoot => Dir.getwd, | |
} | |
ARGV.options do |opts| | |
script_name = File.basename($0) | |
opts.separator "" | |
opts.on("-p", "--port=port", Integer, "port number") {|v| | |
OPTIONS[:Port] = v | |
} | |
opts.on("-b", "--bind=binding-address", String, "binding address") {|v| | |
OPTIONS[:BindingAddress] = v | |
} | |
opts.parse! | |
end | |
s = HTTPServer.new(OPTIONS) | |
trap("INT"){ | |
s.shutdown | |
} | |
s.start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment