Flask BuildError:无法为终结点';main.index';。你是说';指数';相反

Flask BuildError:无法为终结点';main.index';。你是说';指数';相反,flask,Flask,我正在尝试加载我的索引Html页面,但我一直得到“无法为端点“main.index”构建URL”。你是说“索引”吗?改为“错误” 知道怎么了吗 from flask import Flask, render_template app = Flask(__name__, template_folder="templates") @app.route('/') def index(): return render_template("index.html") if __name__

我正在尝试加载我的索引Html页面,但我一直得到“无法为端点“main.index”构建URL”。你是说“索引”吗?改为“错误”

知道怎么了吗

from flask import Flask, render_template

app = Flask(__name__, template_folder="templates")


@app.route('/')
def index():
    return render_template("index.html")


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

{% extends "Base.html" %}
{% block content %}

<div>
    <p>
        Hello
    </p>
</div>
{% endblock %}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Wooe</title>
    <link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<section>
    <header>
        <h1>
            Parent Watch
        </h1>
        <nav>
            <a href="{{ url_for('main.index') }}" class="navbar-item">Home</a>
            <a href="{{ url_for('main.profile') }}" class="navbar-item">Profile</a>
            <a href="{{ url_for('auth.login') }}" class="navbar-item">Login</a>
            <a href="{{ url_for('auth.signup') }}" class="navbar-item">Sign Up</a>
            <a href="{{ url_for('auth.logout') }}" class="navbar-item">Logout</a>
        </nav>
    </header>
</section>
<div>
    {% block content %}
    {% endblock %}
</div>

</body>
{%extends“Base.html”%}
{%block content%}

你好

{%endblock%}
Base.html

{% extends "Base.html" %}
{% block content %}

<div>
    <p>
        Hello
    </p>
</div>
{% endblock %}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Wooe</title>
    <link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<section>
    <header>
        <h1>
            Parent Watch
        </h1>
        <nav>
            <a href="{{ url_for('main.index') }}" class="navbar-item">Home</a>
            <a href="{{ url_for('main.profile') }}" class="navbar-item">Profile</a>
            <a href="{{ url_for('auth.login') }}" class="navbar-item">Login</a>
            <a href="{{ url_for('auth.signup') }}" class="navbar-item">Sign Up</a>
            <a href="{{ url_for('auth.logout') }}" class="navbar-item">Logout</a>
        </nav>
    </header>
</section>
<div>
    {% block content %}
    {% endblock %}
</div>

</body>

求爱
家长表
{%block content%}
{%endblock%}

我已经添加了索引Html文件以及索引文件扩展的基本Html文件

根据问题中显示的代码猜测,似乎您正在尝试在
index.Html中执行以下操作


由于我没有注意到问题代码中任何地方的创建,请将其更改为



@AlmeeBoyle您可以显示
index.html
的代码吗?您只需使用
href=“{{url\u for('index')}}”
而不是
href=“{{url\u for('main.index')}”
更改页面正在加载的href即可。Thanks@AlmeeBoyle请把给出的答案投上去,这样可以帮助别人。