Created
February 18, 2014 19:51
-
-
Save mikedemers/9078610 to your computer and use it in GitHub Desktop.
serve.rb
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' | |
include WEBrick | |
# add custom MIME types | |
HTTPUtils::DefaultMimeTypes.store('swf', 'application/x-shockwave-flash') | |
port = rand(1000) + 4000 | |
path = File.expand_path((ARGV[0].nil?) ? File.dirname(__FILE__) : ARGV[0]) | |
STDERR.puts "#{$0}: port #{port} serving \"#{path}\"" | |
server = HTTPServer.new(:Port => port, :DocumentRoot => path, :DocumentRootOptions => {:FancyIndexing => true}) | |
trap("INT"){ server.shutdown } | |
server.start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment