Home > database >  werkzeug.routing.BuildError: Could not build url for endpoint 'auth'. Did you mean 'd
werkzeug.routing.BuildError: Could not build url for endpoint 'auth'. Did you mean 'd

Time:03-18

I'm trying to make a dashboard for my discord bot, And I use 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 >
                  <a href="{{ url_for('auth') }}" >Login</a>
               </div>
                            {% else %}
                            <div >
                  <a href="{{ url_for('dashboard') }}" ><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!

CodePudding user response:

{{ url_for('auth') }}

instead try

{{ url_for('login') }}

or if blueprint

{{ url_for('.login') }}
  • Related