Monday, August 13, 2012

Simple HTTP server using Python


1) Change to your www directory, a location of your files, include at least index.html:

$ cd /Users/uki/Python/web/SimpleHTTPServer/www 

2) Start server at port you want:

$ python -m SimpleHTTPServer 8080


3) Open: http://localhost:8080/

4) Monitor requests:


uki:www uki$ python -m SimpleHTTPServer 8080
Serving HTTP on 0.0.0.0 port 8080 ...
1.0.0.127.in-addr.arpa - - [13/Aug/2012 20:21:00] "GET / HTTP/1.1" 200 -
1.0.0.127.in-addr.arpa - - [13/Aug/2012 20:21:00] code 404, message File not found
1.0.0.127.in-addr.arpa - - [13/Aug/2012 20:21:00] "GET /favicon.ico HTTP/1.1" 404 -
1.0.0.127.in-addr.arpa - - [13/Aug/2012 20:21:12] "GET / HTTP/1.1" 200 -
1.0.0.127.in-addr.arpa - - [13/Aug/2012 20:21:12] code 404, message File not found
1.0.0.127.in-addr.arpa - - [13/Aug/2012 20:21:12] "GET /favicon.ico HTTP/1.1" 404 -