Last Updated: February 20, 2016
·
1.396K
· ejholmes

Serve a local directory with WEBrick

It's easy to serve a local directory over HTTP with WEBrick. Just throw the following in your ~/.bash_profile or ~/.zshrc:

alias served="ruby -r webrick -e \"s = WEBrick::HTTPServer.new(:Port => 9090, :DocumentRoot => Dir.pwd); trap('INT') { s.shutdown }; s.start\""

Then cd to the directory you want to serve and type served. Point your browser to http://localhost:9090 and wala!

Gist at https://gist.github.com/1766379