Quick and dirty hacks: one line HTTP Server

SimpleHTTPServer with Python

Some times you just want to prove a concept by running a web server on a server, or even your desktop somewhere. The problem is, it seems a bit overkill to install a whole web server on a host, just to get a few pages served up, right?

Well, as long as your machine has python on it (almost every linux box does these days), you can set up a web server, in one eensy weensy line:

$python -m SimpleHTTPServer

By default, this will listen on all interfaces, on port 8080. If you want to make it listen on the usual HTTP port, port 80, then you need to be root, and tell it to listen on port 80:

$sudo python -m SimpleHTTPServer 80

Enjoy!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.