[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)

[python] Start a http server_第1张图片

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

[python] Start a http server_第2张图片

 

BTW.  On linux,

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

python –m simpleHTTPServer 8000 &

你可能感兴趣的:([python] Start a http server)