[python] Start a http server

If you want to start a simple httpserver on your windows, you may choose python.simpleHTTPServer module.

1. install python

2. create an directory, which will be listed. (in eclipse, you may create a pydev project)

image

3. create a .py file, such as

http://docs.python.org/2/library/simplehttpserver.html

import SimpleHTTPServer
import SocketServer

PORT = 8000

Handler = SimpleHTTPServer.SimpleHTTPRequestHandler

httpd = SocketServer.TCPServer(("", PORT), Handler)

print "serving at port", PORT
httpd.serve_forever()

 

Then go to http://localhost:8000/, you will see

image

 

BTW.  On linux,

cd <dir-you-want-to-list>

python –m simpleHTTPServer 8000 &

posted @ 2013-06-18 12:26  lizmy  阅读(575)  评论(0编辑  收藏  举报