Skip to content

Instantly share code, notes, and snippets.

@s-shin
Last active December 21, 2015 05:49
Show Gist options
  • Select an option

  • Save s-shin/6259910 to your computer and use it in GitHub Desktop.

Select an option

Save s-shin/6259910 to your computer and use it in GitHub Desktop.
ワーキングディレクトリをパプリックディレクトリにする簡易サーバ。ローカル内でファイル転送したい時に便利。 $ ruby -e "$(curl -fsSL https://gist.github.com/s-shin/6259910/raw/torimasaba.rb)" で一時保存も必要なし。
require "webrick"
server = WEBrick::HTTPServer.new({
DocumentRoot: "./",
Port: ARGV[0] ? ARGV[0].to_i : 8080,
MimeTypes: WEBrick::HTTPUtils::DefaultMimeTypes.merge({
"js" => "application/javascript"
})
})
server.mount("/", WEBrick::HTTPServlet::FileHandler, Dir.pwd, {FancyIndexing: true})
trap("INT") { server.shutdown }
server.start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment