Note: This guide is for Python 2. See the follow up post for how to do this with Python 3.

The other day my colleague Sam Starling pointed out an incredibly rapid way to start up an http server using Python 2’s SimpleHTTPServer module:

python -m SimpleHTTPServer

This instantly creates an http server bound to with a content root of the current directory. It can be exited using ctrl-c. This is really useful for quickly running static websites that maybe have absolute paths to reference resources, or for quickly sharing files over http.