Skip to content

Instantly share code, notes, and snippets.

@takai
Created June 4, 2009 00:57
Show Gist options
  • Save takai/123366 to your computer and use it in GitHub Desktop.
Save takai/123366 to your computer and use it in GitHub Desktop.
# -*- mode: ruby; coding: utf-8-unix -*-
require 'time'
require 'webrick'
server = WEBrick::HTTPServer.new(:BindAddress => '0.0.0.0',
:Port => 3000,
:DocumentRoot => ARGV.shift || Dir::pwd)
server.mount("/",
WEBrick::HTTPServlet::FileHandler,
Dir::pwd,
:FancyIndexing => true,
:FileCallback => Proc.new {|req, res|
res['Cache-Control'] = 'no-cache, no-store, must-revalidate'
res['Expires'] = Time.at(0).httpdate
})
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