当我路由我的 flask 应用程序时,我收到了错误的请求。但我不明白为什么我无法渲染我的 html 模板。
这是我的应用程序路由代码:
@app.rout('/', methods=['POST', 'GET'])
def main_page():
return render_template('sign.html')
@app.route('/sign', methods=['POST', 'GET'])
def SignResource():
data = {
"amount": request.form['amount'],
"payway": request.form['payway'],
"description": request.form['description']
}
这是我的模板表单:
<form action = "http://localhost:5000/sign" method = "post">
<div class="pay_info">
<input type="text", name='amount', value="12.34">
<input list="currency_list" name="payway" autofocus>
<datalist id="currency_list" >
<option value="RUB">
<option value="USD">
<option value="EUR">
</datalist>
<div class='description_text'>
<input type="text", name='description', value='Test description'>
</div>
<input type="submit">
</form>
在模板中,我在 html 表单上写入数据,然后在“/sign”路径中解析它。 但是当我尝试渲染 html 时,我得到了代码 400
最佳答案
以下代码中路线的拼写错误:
@app.rout('/', methods=['POST', 'GET'])
def main_page():
return render_template('sign.html')
更正:
@app.route('/', methods=['POST', 'GET'])
def main_page():
return render_template('sign.html')
关于python - Flask 路由模板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59528496/