SimpleHTTPServer

Whilst reading about BaseHTTPServer class as mentioned in the last post, I also came across the very useful SimpleHTTPserver which is most definitely worth recording as a one-liner. Everybody must have come across the situation where you're ssh'd into a headless server with no Apache installed or running on it, and you come across an HTML file you want to look at. You can read it with vi (or lynx!) but that's never really going to be that nice. As python is near-ubiquitous on all Linux installations these days, you can run this simple oneliner to view HTML docs on the system (or in fact any files you might want to view graphically instead of via a terminal?)

1server:/usr/share/doc/bash-3.2$ python -m SimpleHTTPServer 8000
2Serving HTTP on 0.0.0.0 port 8000 ...
3127.0.0.1 - - [16/Aug/2013 17:51:49] "GET / HTTP/1.1" 200 -