Flask-Web-App-Tutorial
Flask-Web-App-Tutorial copied to clipboard
werkzeug.routing.BuildError
I'm not sure why I keep having this issue. I check my code since I assumed the problem was in the log-out function but I'm not really sure how to fix it. This is what the rest of the message says: werkzeug.routing.BuildError: Could not build url for endpoint 'auth.login'. Did you mean 'auth.logout' instead?
this is the function I have for log out: def logout():
logout_user()
#return "<p> You're now log out!</p>"
return redirect(url_for('auth.login')) # or 'auth.login'
please help
FYI i changed it to 'auth.logout' and still doesn't work
Do you have route above this section of code?
@auth.route('/logout') <----THIS IS THE ROUTE @login_required def logout(): logout_user() return redirect(url_for('auth.login'))
Hey @jvivar2383 the error occurs when it does find an route to a particular URL the auth.login
points to a function named login()
inside the auth
object please recheck if there is any Typo error
@auth.route('/login', methods=['GET', 'POST'])
def login():
...
return render_template("login.html", user=current_user)
@auth.route('/logout')
@login_required
def logout():
logout_user()
return redirect(url_for('auth.login'))