区分 CherryPy 中的 GET 和 POST 数据?
我一直在为我的一个项目选择 Python Web 框架,我非常喜欢 CherryPy 与其他框架相比的轻量级、灵活和简洁。我遇到的唯一问题是我找不到任何有关如何区分通过 GET 和通过 POST 发送的数据的文档。
例如,我不希望用户能够通过 GET 请求 (http://example.com/login?username=user&password=pass) 提供他们的登录凭据,但是,根据 CherryPy 的教程,所有数据都作为方法参数发送,无论它们作为哪种 HTTP 方法发送。有没有办法说我只想要 POST 数据或者我必须使用 方法调度程序?
谢谢!
I've been deciding between Python web frameworks for a project of mine and I've really liked how lightweight, flexible, and concise CherryPy is compared to others. The only problem I'm having is I can't find any documentation on how to distinguish between data sent via GET and via POST.
For example, I don't want users to be able to provide their login credentials through a GET request (http://example.com/login?username=user&password=pass) but, according to CherryPy's tutorial, all data is sent as method parameters, no matter what HTTP method they're sent as. Is there some way to say I only want the POST data or do I have to use MethodDispatcher?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请参阅文档。
看起来检查cherrypy.request.method 是你想要做的。
See the docs.
looks like checking cherrypy.request.method is what you want to do.