Python如何获取所接收到的POST数据包中的内容

无烟无酒亦无妞 2014-11-20 09:32:51


#!/usr/bin/env python
# -*- coding: utf-8 -*-

import web

urls=('/test','Test')

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

class Test:
def GET(self):
#return the resource (group) details
return 'GetTest'

def PUT(self):
#update the resource
return 'PutTest'

def POST(self):
#creat/update the resource
postContent = '' #此处如何获取所接收到的POST数据包中的内容???
print
return postContent

def DELETE(self,resourceId):
#delete the resource
return 'DeleteTest'

if __name__ == '__main__':
app.run()



上面这个web.py框架的webService已经可以正常运行了。这时候,我使用一个POST工具发个包(如下图),我希望能获取到这个包里的POST内容(下图中的testContent),并赋值给上面的postContent变量,请问要import什么模块,具体怎么实现?

...全文
3100 1 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
panghuhu250 2014-11-20
  • 打赏
  • 举报
回复 1
这应该是每个framework的文档里都提到的。看教程,看文档。例如这儿: http://webpy.readthedocs.org/en/latest/input.html

37,743

社区成员

发帖
与我相关
我的任务
社区描述
JavaScript,VBScript,AngleScript,ActionScript,Shell,Perl,Ruby,Lua,Tcl,Scala,MaxScript 等脚本语言交流。
社区管理员
  • 脚本语言(Perl/Python)社区
  • WuKongSecurity@BOB
加入社区
  • 近7日
  • 近30日
  • 至今

试试用AI创作助手写篇文章吧