Я получаю следующую ошибку всякий раз, когда пытаюсь отправить данные в форму Flask:
Method Not Allowed
The method is not allowed for the requested URL.
Код:
app.py
@app.route('/create-article', methods=['POST', 'GET'])
def createaritcle():
if request.method == "POST":
title = request.form['title']
intro = request.form['intro']
text = request.form['text']
article = Article(title=title, intro=intro, text=text)
try:
db.session.add(article)
db.session.commit()
return redirect("/")
except:
return "Ошибка"
else:
return render_template("create-article.html")
create-article.html
{% extends 'base.html' %}
{% block title %}
1
{% endblock %}
{% block body%}
<div class="container mt-5">
<form method="POST">
<input type="text" name="title" id="title" class="form-control"><br>
<textarea name="intro" class="form-control"></textarea><br>
<textarea name="text" class="form-control"></textarea><br>
<input type="submit" class="btn btn-success" value="Отправить">
</form>
</div>
{% endblock %}