Yehuda Katz is a member of the Ember.js, Ruby on Rails and jQuery Core Teams; he spends his daytime hours at the startup he founded, Tilde Inc.. Yehuda is co-author of best-selling jQuery in Action and Rails 3 in Action. He spends most of his time hacking on open source—his main projects, like Thor, Handlebars and Janus—or traveling the world doing evangelism work. He can be found on Twitter as @wycats and on Github.
August 6th, 2007
I’ve lately found myself frequently in a situation where I had a directory structure that I wanted to be able to easily browse like a server. One common reason for me was a desire to browse work I was doing on my Mac on Parallels.
Rails uses Webrick to quickly mount its directory structure, and since my needs were very lightweight, I decided to investigate how I could set up webrick to mount a directory structure on a particular port. The result: a small script called server.rb which you can drop into any folder and call via
ruby server.rb [PORT]. It’ll default to port 2000.
The code is almost entirely the example code from the Webrick library, but there are a few modification. Bon Apetit!