Quick Tip: Start a Web Server in the Current Directory

I’ve found myself working on a static HTML website recently (hosted on GitHub Pages), and I wanted to test the site without going through the effort of configuring Apache. This one-liner is a combination of two ideas that use Ruby’s built-in WEBrick web server to serve the files in the current working directory.

I added this as an alias to my bash profile, so I can type servhere and host any directory I want. Cool!