Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/318.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何使用web.py发送HTTP响应和接收HTTP请求?_Python_Web.py - Fatal编程技术网

Python 如何使用web.py发送HTTP响应和接收HTTP请求?

Python 如何使用web.py发送HTTP响应和接收HTTP请求?,python,web.py,Python,Web.py,我想构建一个web服务,该服务使用web.py,并希望支持脚本发送响应和接收请求 app = web.application(urls, globals()) class index: def GET(self): return "Hello, world!" def POST(self): webdata = web.data() #use script to send response and receive re

我想构建一个web服务,该服务使用web.py,并希望支持脚本发送响应和接收请求

    app = web.application(urls, globals())

class index:

    def GET(self):
        return "Hello, world!"

    def POST(self):
        webdata = web.data()
        #use script to send response and receive request.
        return webdata 

但是我找不到任何方法来实现这个特性,我想知道在web.py或其他库中可以使用哪个API

嗯。如果您正确使用web.py,那么当前代码基本上应该这样做。所有web框架都是一种接收HTTP请求并在响应中返回代码结果的奇特方式。如何分配URL?你试过这个吗?