私はFlaskを学び始めたばかりで、POSTメソッドを許可するフォームを作成しようとしています。
これが私の方法です:
@app.route('/template', methods=['GET', 'POST'])
def template():
if request.method == 'POST':
return("Hello")
return render_template('index.html')
そして私のindex.html
:
<html>
<head>
<title> Title </title>
</head>
<body>
Enter Python to execute:
<form action="/" method="post">
<input type="text" name="expression" />
<input type="submit" value="Execute" />
</form>
</body>
</html>
フォームの読み込み( GETを受け取ったときにレンダリングする)は正常に機能します。ただし、送信ボタンをクリックすると、が表示されますPOST 405 error Method Not Allowed
。
「こんにちは」と表示されないのはなぜですか?