Question:
I’d like to know how to create a custom 404 page while using Flask.
Maybe try coding a 404 page in html then transfer the code into flask
i dont know much about web dev but you could probably just make a custom html 404 page, and then whenever you encounter a 404 error in the backend you just redirect to that page.
Add this to your code:
@app.errorhandler(404)
def _404(e):
return f"<h1>{e}</h1>"
# "e" is actually the complete 404 error message
# You can use render_template and stuff too
3 Likes
So you don’t blind your users with light mode.
Fr though, you may want to link them back to the home page or something.
2 Likes
If your user goes to a page that doesn’t exist, you’ll want them to just be a click away from being able to go back to the home page.
Or if you’re confused about my joke at the beginning, default error pages on flask have a “blinding” white background.
4 Likes
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.