Issue
I am creating a web application and I would like to do a styled 404 page not found if someone tries to enter one of my routes that is not created. Is there a way I can do this?
Solution
welcome to stackoverflow!
To create a error handler of any error code in flask you must do the following, for my example I will use a 404
error as requested in the post:
@app.errorhandler(404)
def page_not_found(e):
return render_template('404.html'), 404
If you want to error handle a 505
just substitut the 404
for a 505
and create a new html file in templates
Answered By - OlauPla
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.