22 lines
296 B
Plaintext
22 lines
296 B
Plaintext
|
[[Category:Ruby]]
|
||
|
|
||
|
<source lang="ruby">
|
||
|
#!/usr/local/bin/ruby
|
||
|
require 'webrick'
|
||
|
include WEBrick
|
||
|
|
||
|
if ARGV.size != 2
|
||
|
puts "Usage: #{$0} <port> <dir>"
|
||
|
exit
|
||
|
end
|
||
|
|
||
|
s = HTTPServer.new(
|
||
|
:Port => ARGV[0].to_i,
|
||
|
:DocumentRoot => ARGV[1]
|
||
|
)
|
||
|
|
||
|
|
||
|
trap("INT"){ s.shutdown }
|
||
|
s.start
|
||
|
</source>
|