How to receive and parse a HTTP incoming request using python?
How to receive and parse a HTTP incoming reque开发者_如何学Gost using python?
You can do:
python -m SimpleHTTPServer 8080
By default it serves the current working directory.
To get an idea of how this is put together/parses the requests or to work out how to build one for your own needs, look at the "SimpleHTTPServer.py" module in the lib directory of your python install.
You could also look at the built in webservers that the web frameworks like django, werkzeug, cherry-py provide. Stackoverflow has quite a few interesting questions.
There are dozens of solutions for this, of all kinds and flavors.
The most basic would be SimpleHTTPServer mentioned by @davey.
Other options would be:
http://webpy.org/ - simple, lightweight framework
http://www.tornadoweb.org/ - flexible and scalable web server
http://twistedmatrix.com/trac/wiki/TwistedWeb - single-threaded, event-driven server and framework
http://bottle.paws.de/ - single-file server and framework
精彩评论