【问题标题】:405 Method not allowed with POST + FlaskPOST + Flask 不允许使用 405 方法
【发布时间】:2017-09-21 06:28:25
【问题描述】:

当我尝试使用烧瓶通过 POST 将表单传递给 python 脚本时,我发现了 405 错误。

我的 Python 是这样的:

@app.route('/make', methods=['POST', 'GET'])
def make():
    if request.method == 'POST':
        return "its working"

我的表格是这样的:

<form method="POST" target="/make">
        <div id="Question">
</form>

我的代码有点大,所以我没有完全复制它。我似乎找不到我的错误。我做错了什么?

【问题讨论】:

  • 你不是要使用action 代替target 吗? target 将在 /make 打开一个新页面,这是一个 get。

标签: python html post flask


【解决方案1】:

在您的表单中,您需要使用action 而不是target

<form method="POST" action="/make">
        <div id="Question">
</form>

更多详情:form_action

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-08-24
    • 1970-01-01
    • 2016-02-15
    • 2014-04-18
    • 2014-05-23
    • 2018-12-20
    • 2015-11-16
    • 2016-05-15
    相关资源
    最近更新 更多