Skip to content

Instantly share code, notes, and snippets.

@thejandroman
Forked from mikedemers/serve.rb
Last active August 29, 2015 13:56
Show Gist options
  • Save thejandroman/9078631 to your computer and use it in GitHub Desktop.
Save thejandroman/9078631 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'webrick'
include WEBrick
# add custom MIME types
#HTTPUtils::DefaultMimeTypes.store('swf', 'application/x-shockwave-flash')
port = 8081
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