Python's Built-in HTTP Server

If I could count the number of times I wanted to share something on my computer with someone else in my home or office, it would be a big number.

Quite freququently, it wasn't worth the trouble of using e-mail, scp, or a USB drive, and definitely not worth pushing to an actual site so that anyone can see it. Or it was easier to just have them come look at my screen.

Maybe I'm just looking at my latest build of Sphinx documentation and want an opinion, or maybe I just ran gitstats at work and want to show someone the recent activity.

Well, once again, Python to the rescue! Python has a SimpleHTTPServer module which can be used from the command line:

cd /path/to/your/stuff
python -m SimpleHTTPServer

As easy as that, you're now running a Web server on your local IP address. The default is port 8000. If you want to run at a specific port, just add the port number to the command line:

python -m SimpleHTTPServer 5555

Now you can share static content with anyone on your network on a whim.

Comments !

blogroll

social