python’s HTTP server

Python comes with an HTTP server built in, making sharing directories on your *nix machines as easy as:

anton@opensolaris:~/mess/test$ python -m SimpleHTTPServer
Serving HTTP on 0.0.0.0 port 8000 …
localhost – - [26/Sep/2009 00:23:47] “GET / HTTP/1.0″ 200 -
localhost – - [26/Sep/2009 00:24:24] “GET / HTTP/1.1″ 200 -

So now when we go to localhost:8000 , we get the directory!:

anton@opensolaris:~/mess$ lynx -dump localhost:8000
Directory listing for /
__________________________________________________________________

* [1]lalala
__________________________________________________________________

References

1. http://localhost:8000/lalala

…or…

anton@opensolaris:~$ lynx -source localhost:8000
<title>Directory listing for /</title>
<h2>Directory listing for /</h2>
<hr>
<ul>
<li><a href=”lalala”>lalala</a>
</ul>
<hr>

…for those of you that want to see the source it produced! A very quick short term solution if you don’t want to go about setting up apache or change your apache settings!

Leave a Reply