Last active
December 15, 2015 02:09
-
-
Save zerobase/5185437 to your computer and use it in GitHub Desktop.
Simple WEBrick Command.
(My ruby version: ruby 1.9.3p392 (2013-02-22 revision 39386) [x86_64-darwin12.2.0])
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' | |
require 'optparse' | |
port = 8000 | |
root = '.' | |
OptionParser.new do |opt| | |
opt.on('-p', '--port PORT', "default: #{port}") { |v| port = v } | |
opt.on('-d', '--directory DOCUMENT_ROOT', "default: #{root}") { |v| root = v } | |
opt.parse! | |
end | |
server = WEBrick::HTTPServer.new :Port => port, :DocumentRoot => root | |
trap 'INT' do server.shutdown end | |
server.start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment