我正在使用webapp2来制作一个小api。
因此,例如,如果我有:
import webapp2
class Test(webapp2.RequestHandler):
def put(self):
self.response.write("this was a test")
app = webapp2.WSGIApplication([
('/test', Test)
])我通过卷曲做了一个请求:
curl --request PUT --header "Content-Type: application/json" --data '{"content": "test"}' http://localhost:8080/test我将如何访问传入的数据'{"content": "test"}'?
发布于 2018-04-13 23:09:07
所有请求数据都位于self.request中的某个位置,因此在本例中,请查看self.request.body以查找请求的内容,并查看文档的公共请求属性部分,以查看其余选项。
您还可以考虑查看调试器中的整个self对象,以了解它所具有的更有趣的属性。
https://stackoverflow.com/questions/49820985
复制相似问题