Simple Python HTTP Server

Linux Journal posted a nifty Python trick to quickly share files on your network. It should work anywhere that Python does (i.e. anywhere). Just CD to the directory you want to share and type:

python -m SimpleHTTPServer

Anybody that navigates to http://yourmachine:8000 (the default port) will be able to go mucking through that directory and its sub directories. If you’re like me and have lots of stuff running on 8x ports, you can specify the port number at the end off the command. Note this is a built-in Python library. Python doesn’t have the “Batteries Included” moniker for nothing.

Python has made some noise as a capable web server lately with projects like Tornado, which powers FriendFeed, popping up left and right. I’m curious to see where it all plays out in a year or two. Running a Python web application on top of a Python web server has a certain poetry to it.

Editor’s Note: SimpleHTTPServer was merged under http.server at Python 3.x. But I’ve yet to run across anybody doing much with 3.x.