问题描述
限时送ChatGPT账号..我正在尝试在 Tornado 网络服务器中发布表单,但每当我单击提交时,都会生成以下错误
I'm trying to post a form in Tornado web server but whenever I click submit the following error generates
405 方法不允许
这是表格
<form method="post">
First name: <input type="text" name="fname"><br>
Last name: <input type="text" name="lname"><br>
<input type="submit" value="Submit">
</form>
我尝试将主请求处理程序上的get"方法更改为post",但它不起作用.唯一有效的方法是 GET,
I've tried changing the "get" method on the main Request Handler to "post" but it doesn't work. The only method that works is GET,
class MainHandler(BaseHandler):
"""
Main request handler for the root path and for chat rooms.
"""
@tornado.web.asynchronous
def get(self, room=None):
有什么建议吗?
推荐答案
在那段漫长的聊天窗口之后,我发现最适合您的方法是通过 cookie 传输数据.
After that long window of chat I've figured that the best method for you specifically is to transfer the data through cookies.
这是一个教程:http://www.w3schools/js/js_cookies.asp
另一种资源是将您的数据分解为多个部分.
An alternative resource is to breakdown your data into multiple parts.
一种方法是向为您分配唯一 ID 的端点发出请求.然后以 ?id=XXX&page=1&data=...
的形式发送一系列请求,然后用 ?id=XXX&total_pages=27
关闭它此时您将在服务器上组装不同的部分.
One approach would be to make a request to an end point that allocates you a unique ID. Then send a series of requests in the form: ?id=XXX&page=1&data=...
before closing it with ?id=XXX&total_pages=27
at which point you assemble the different pieces on the server.
这篇关于未找到 Tornado Post 方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
更多推荐
[db:关键词]
发布评论