简体   繁体   English

所请求的URL不允许使用该方法-Flask + HTML

[英]The method is not allowed for the requested URL - Flask + HTML

I am getting the message "The method is not allowed for the requested URL" on my html page. 我在html页面上收到消息“请求的URL不允许使用该方法”。 I know the problem is with POST method but can't find that out. 我知道问题出在POST方法上,但找不到。

My program is to list out the entries in one session. 我的程序是在一个会话中列出条目。

PYTHON: 蟒蛇:

from flask import Flask, render_template, request, session
from flask_session import Session

app = Flask(__name__)

app.config["SESSION_PERMANENT"] = False
app.config["SESSION_TYPE"] = "filesystem"
Session(app)

notes = []

@app.route("/", methods=["GET","POST"])
def index():
    if request.method == "POST":
        note = request.form.get("note")
        notes.append(note)


    return render_template("index.html", notes=notes)

if __name__ == '__main__':
    app.run(debug = True)

HTML: HTML:

{% extends "layout.html" %}

{% block heading %}
  NOTES
{% endblock %}

{% block body %}

<ul>
    {% for note in notes %}
        <li>{{ note }}</li>
    {% endfor %}
</ul>

<form action="{{ url_for('index') }}" method="post">
    <input type="text" name="note" placeholder="Type Here">
    <button>Add Note</button>
</form>

{% endblock %}

I want a list of entries but getting the error - The method is not allowed for the requested URL. 我需要条目列表,但收到错误-请求的URL不允许使用该方法。

添加类型=''提交''为我工作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Flask - POST - 请求的URL不允许使用该方法 - Flask - POST - The method is not allowed for the requested URL 所请求的URL不允许使用该方法。 在烧瓶 - The method is not allowed for the requested URL. in Flask Python Flask:错误“请求的 URL 不允许使用该方法” - Python Flask: Error "The method is not allowed for the requested URL" 如何修复 Flask 中的“请求的 URL 不允许使用该方法” - How to fix "The method is not allowed for the requested URL" in Flask 不允许的方法 请求的 URL 不允许使用该方法。 在 DELETE 方法烧瓶上 - Method Not Allowed The method is not allowed for the requested URL. on DELETE Method Flask Python、Flask:方法不允许,请求的方法不允许 URL - Python, Flask: Method Not Allowed, The method is not allowed for the requested URL Flask 错误:“方法不允许 请求的 URL 不允许该方法” - Flask Error: “Method Not Allowed The method is not allowed for the requested URL” Flask 错误:“方法不允许 请求的 URL 不允许该方法” - Flask Error: "Method Not Allowed The method is not allowed for the requested URL" Flask 错误:方法不允许 请求的 URL 不允许该方法 - Flask error: Method Not Allowed The method is not allowed for the requested URL Python flask flask不允许的方法所请求的URL不允许使用该方法 - Python flask Method Not Allowed The method is not allowed for the requested URL
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM