Ever need a quick and dirty web server running on your machine?  Well if you have Python loaded – here’s what you do.

A Quick Python (test) WebServer

When I need to serve up a few files for friends or try out some CGIs, XML-RPC, etc. I generally just fire up the PythonCard webserver sample. However, I find the following single line at a command prompt to be quite appealing for an instant web server.

    python -c "import SimpleHTTPServer;SimpleHTTPServer.test()"

It works on any OS where you have Python installed and since you can cd (change directory) to the dir you want to serve files from before running the command you don’t have to mess with config files or moving files before serving them up. If you alias the command or make a batch file you won’t have to remember the whole line. Here’s an example run on my Mac.

admins-macbook-pro-2:Applications admin$ python -c "import SimpleHTTPServer;SimpleHTTPServer.test()"
Serving HTTP on port 8000 ...
practivate.adobe.com - - [02/Feb/2010 17:49:05] "GET / HTTP/1.1" 200 -