Tuesday, April 13, 2010

Simple Web Server in Python

I just recently learned about the simple web server capability of Python's SimpleHTTPServer module.  To instantly create a web server and serve a directory tree of files, cd to the tree root and run the following command.

python -m SimpleHTTPServer

This will start a web server on the indicated port which should be 8000.

Of course, do this cautiously!  It's great if you know what you are doing.  It could be risky if you don't.