Sunday, August 01, 2010

My favourite Python one-liner

I am slowly working on two new projects involving web-based interactive Python tutorials and had to set up a local web server for handling ajax request.  After browsing the web, I stumbled upon the following one-liner in the Python documentation that I had completely forgotten about:

 python -m SimpleHTTPServer 8000

Then, simply pointing the browser at "http://localhost:8000" and all is set to go.  Granted, it is not what one might consider a traditional "one-liner" but it works for me.  Python's batteries included is certainly a nice feature!

2 comments:

Anonymous said...

Hi, just wanted to let you know that you don't even need to specify the port number, it's the default. ;-)

Kolor said...

This is so Kickass..!