Feature #8586 ยป fs.patch
| lib/webrick/simple.rb | ||
|---|---|---|
|
require 'webrick'
|
||
|
###
|
||
|
# Simple WEBrick file server. Usage:
|
||
|
#
|
||
|
# Start the file server, serving the files in the current directory
|
||
|
#
|
||
|
# $ ruby -rwebrick/simple -e start
|
||
|
#
|
||
|
# Start the file server, serving the files in the current directory on
|
||
|
# port 5000.
|
||
|
#
|
||
|
# $ ruby -rwebrick/simple -e start 5000
|
||
|
#
|
||
|
# Start the file server, serving the files in /tmp on port 5000.
|
||
|
#
|
||
|
# $ ruby -rwebrick/simple -e start 5000 /tmp
|
||
|
def start
|
||
|
port = ARGV.fetch 0, 0
|
||
|
root = ARGV.fetch 1, '.'
|
||
|
s = WEBrick::HTTPServer.new(:DocumentRoot => root, :Port => port)
|
||
|
trap('INT') { s.shutdown }
|
||
|
s.start
|
||
|
end
|
||