python-3.x – CherryPy:如何将路由限制为仅限POST

python-3.x – CherryPy:如何将路由限制为仅限POST,第1张

概述我有一个网页形式,看起来像: <form action="/process_form/" method="post"> <input type="text" name="login" value="login" /> <input type="text" name="password" value="123" /> <input type="submit" /></form> 处理这 我有一个网页形式,看起来像:

@H_301_11@<form action="/process_form/" method="post"> <input type="text" name="login" value="login" /> <input type="text" name="password" value="123" /> <input type="submit" /></form>

处理这个问题的python类是:

@H_301_11@class Handle: @cherrypy.expose() #@cherrypy.tools.post <-- Is something like this possible def index(self,login=None): print(login)

在CherryPy中是否有办法将对/ process_form /的调用限制为POST方法?我的意思是如果用户键入http://www.example.com/process_form/他/她应该得到异常/错误或找不到页面?

解决方法 Allow tool将提高405.

@H_301_11@@cherrypy.tools.allow(methods=['POST']) 总结

以上是内存溢出为你收集整理的python-3.x – CherryPy:如何将路由限制为仅限POST全部内容,希望文章能够帮你解决python-3.x – CherryPy:如何将路由限制为仅限POST所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://www.54852.com/langs/1192785.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-06-03
下一篇2022-06-03

发表评论

登录后才能评论

评论列表(0条)

    保存