Aimee Boyle
Aimee Boyle

Reputation: 11

BuildError: Could not build url for endpoint 'main.index'. Did you mean 'index' instead?

I am trying to load my index Html page but I keep getting the 'Could not build URL for endpoint 'main.index'. Did you mean 'index' instead?' error instead.

Any idea what's wrong

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 %}

Base.html

<!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>

I have added the index Html files as well as the base Html file that the index file extends

Upvotes: 0

Views: 332

Answers (1)

kellymandem
kellymandem

Reputation: 1769

Am guessing from the code shown in the question, it seems you are trying to do the following in your index.html

<a href="{{ url_for('main.index') }}">Home</a>

and since I have not noticed the creation of blueprints anywhere in the code in the question, please change it to

<a href="{{ url_for('index') }}">Home</a>

Upvotes: 1

Related Questions