Skip to content

Instantly share code, notes, and snippets.

@shokai
Created July 18, 2011 21:54
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shokai/1090762 to your computer and use it in GitHub Desktop.
Save shokai/1090762 to your computer and use it in GitHub Desktop.
httpd.rb
#!/usr/bin/env ruby
require 'webrick'
port = 8080
port = ARGV.first.to_i unless ARGV.empty?
#document_root = ENV['HOME']
document_root = './'
server = WEBrick::HTTPServer.new({
:DocumentRoot => document_root,
:BindAddress => '0.0.0.0',
:Port => port
})
['INT', 'TERM'].each {|signal|
Signal.trap(signal){ server.shutdown }
}
server.start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment