gpt4 book ai didi

python - 不允许的方法 - 所请求的 URL 不允许该方法

转载 作者:太空宇宙 更新时间:2023-11-04 08:47:11 27 4
gpt4 key购买 nike

<分区>

我正在尝试构建一个 python flask 应用程序,但是当我尝试将表单数据提交到 python 方法时遇到问题。

服务器抛出的问题是“Method Not Allowed”。

HTML CODE

<h1>Submit the Link</h1>
<form action="/submit_article" method="POST" name="form">
<div class="col-md-4 col-md-offset-4">
{{ form.hidden_tag() }}
<div class="form-group">
<label class="control-label" for="description">Name</label>
{{ form.description }}
</div>
<div class="form-group">
<label class="control-label" for="link">Link</label>
{{ form.link }}
</div>
<button class="btn btn-default" type="submit">Submit</button>
</div>
</form>

PYTHON METHOD (submit_article)

@app.route('/submit_article', methods=['POST'])
def submit_article():
form = UploadForm()
if request.method == 'POST':
data = {
"_id": form.link.data,
"description": form.description.data,
"user": current_user.username,
"time": datetime.datetime.now()
}

try:
if((app.config['NEWS_COLLECTION'].insert(data))):
flash("Link added successfully", category="success")
return redirect(request.args.get("new") or url_for("new"))

except DuplicateKeyError:
flash("Article link already exists in the Database", category="error")
return render_template("submit_article.html")

return render_template('submit_article.html', title='login', form=form)

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com