Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/305.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Post请求时不允许使用Flask 405错误方法_Python_Flask_Post_Routes_Http Status Code 405 - Fatal编程技术网

Python Post请求时不允许使用Flask 405错误方法

Python Post请求时不允许使用Flask 405错误方法,python,flask,post,routes,http-status-code-405,Python,Flask,Post,Routes,Http Status Code 405,我已经运行了一段时间的flask程序,突然出现了405 method not allowed错误 Prodsearch.html <form name="product search" action="" method="post" novalidate> <fieldset class="form-group"> <legend&

我已经运行了一段时间的flask程序,突然出现了405 method not allowed错误

Prodsearch.html

<form name="product search" action="" method="post" novalidate>
            <fieldset class="form-group">
                <legend>Database Search</legend>
                {{ form.hidden_tag() }}
                <p>
                <h6>Search: </h6>
                {{ form.input(size=20) }}
<!--                <input type = "file" name = "file" />-->
                {% for error in form.input.errors %}
                <span class="error-message">{{ error }}</span>
                {% endfor %}
                </p>
                <p>
                    {{ form.submit(class="btn btn-primary") }}
                </p>
            </fieldset>
        </form>
forms.py

class ProdSearch(FlaskForm):
    input = StringField("Enter name search key word", validators=[DataRequired()])
    submit = SubmitField("Search")

我不知道为什么这个错误突然不知从何而来。任何帮助都将不胜感激

尝试将第一条路线更改为

@app.route('/', methods=['GET', 'POST'])

在浏览器中打开“/Prodsearch”时会发生什么情况?它会正确打开。它仅在提交post请求时中断。请尝试将第一个路由更改为
@app.route('/',methods=['GET','post'])
Cool,
@app.route('/', methods=['GET', 'POST'])