'werkzeug.routing.BuildError: Could not build url for endpoint 'auth'. Did you mean 'dashboard' instead?
I'm trying to make a dashboard for my Discord bot, And I use the Flask to do that.
werkzeug.routing.BuildError: Could not build url for endpoint 'auth'. Did you mean 'dashboard' instead?
This error appeared out of nowhere and now I can't get rid of it.
# main.py
...
@app.route('/auth')
def login():
return discord.create_session(scope=["identify", "guilds"])
...
@app.route('/', endpoint="main")
def index_page():
auth = False
userfetch = None
if discord.authorized:
auth = True
userfetch = discord.fetch_user()
return render_template("index.html", authed=auth, user=userfetch)
...
<!-- index.html -->
...
{% if not authed %}
<div class="px-2 d-flex">
<a href="{{ url_for('auth') }}" class="btn btn-primary">Login</a>
</div>
{% else %}
<div class="px-2 d-flex">
<a href="{{ url_for('dashboard') }}" class="btn btn-primary"><img>{{user.avatar_url}}</img>Dashboard</a>
</div>
{% endif %}
...
I just can't get my head around this, I tried changing endpoints for both routes, it still errors. I tried searching on google, still no luck. I'm using Flask-Discord for discord stuff.
If this is an unrecommended library, please give me suggestions what to use!
Solution 1:[1]
{{ url_for('auth') }}
instead try
{{ url_for('login') }}
or if blueprint
{{ url_for('.login') }}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | seimen |
