webrickでwebサーバー作る

http://rubyist.g.hatena.ne.jp/muscovyduck/20061114/p1

これでディレクトリ下が http://localhost:10080/ で公開される。明日飛行機ではこれとC#で遊ぼう

#!/opt/local/bin/ruby
require 'webrick'

document_root = '/Users/sho/'
#document_root = './'

server = WEBrick::HTTPServer.new({
  :DocumentRoot => document_root,
  :BindAddress => '0.0.0.0',
  :Port => 10080
})

['INT', 'TERM'].each {|signal|
  Signal.trap(signal){ server.shutdown }
}

server.start