Skip to content

Instantly share code, notes, and snippets.

@mikedemers
Created February 18, 2014 19:51
Show Gist options
  • Save mikedemers/9078610 to your computer and use it in GitHub Desktop.
Save mikedemers/9078610 to your computer and use it in GitHub Desktop.
serve.rb
#!/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