简体   繁体   English

如何使用python接收和解析HTTP传入请求?

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

如何使用python接收和解析HTTP传入请求?

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. 要了解如何将它们组合在一起/解析请求,或者弄清楚如何构建自己的请求,请查看python安装目录下lib目录中的“ SimpleHTTPServer.py”模块。

You could also look at the built in webservers that the web frameworks like django, werkzeug, cherry-py provide. 您还可以查看django,werkzeug,cherry-py等Web框架提供的内置Web服务器。 Stackoverflow has quite a few interesting questions. Stackoverflow有很多有趣的问题。

There are dozens of solutions for this, of all kinds and flavors. 有各种各样的解决方案,各种类型和口味。

The most basic would be SimpleHTTPServer mentioned by @davey. 最基本的是@davey提到的SimpleHTTPServer。

Other options would be: 其他选项是:

http://webpy.org/ - simple, lightweight framework http://webpy.org/-简单,轻量级的框架

http://www.tornadoweb.org/ - flexible and scalable web server http://www.tornadoweb.org/-灵活且可扩展的Web服务器

http://twistedmatrix.com/trac/wiki/TwistedWeb - single-threaded, event-driven server and framework http://twistedmatrix.com/trac/wiki/TwistedWeb-单线程,事件驱动的服务器和框架

http://bottle.paws.de/ - single-file server and framework http://bottle.paws.de/-单文件服务器和框架

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM