Hitesh Manchanda
Hitesh Manchanda

Reputation: 490

How to receive and parse a HTTP incoming request using python?

How to receive and parse a HTTP incoming request using python?

Upvotes: 0

Views: 3046

Answers (2)

Daniel Kluev
Daniel Kluev

Reputation: 11325

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

Upvotes: 0

gm3dmo
gm3dmo

Reputation: 345

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.

Upvotes: 1

Related Questions