If you do web development and spend most of the day in the command line as I do, you'll appreciate this little productivity tip using Python.

Have you ever just quickly wanted to set up a server without configuring an alias and setting up a root folder? You can use the following command to set one up: 

python -m SimpleHTTPServer 8000

What this will do is take your current folder as the root and run a simple HTTP server on port 8000 (or whatever port you specify). It allows directory listing so you can easily navigate through folders.

For additional convenience, what I do is just set up an alias in ~/.bashrc on my Ubuntu machine or ~/.bash_profile on Mac. 

alias SERVER="python -m SimpleHTTPServer 8000"

What that does is next time I need a local server for a few quick tests, rather than fire up Apache I just navigate to a folder, type SERVER on the command line and open up http://localhost:8000

Posted
AuthorPeter