July 2019
Beginner to intermediate
302 pages
9h 38m
English
Create a method that is decorated with errorhandler() and renders the 404.html template whenever the 404 Not Found error occurs:
@app.errorhandler(404)
def page_not_found(e):
return render_template('404.html'), 404
The following lines of code represent the flask_catalog_template/my_app/templates/404.html template, which is rendered in case of 404 errors:
{% extends 'home.html' %}
{% block container %}
<div class="top-pad">
<h3>Hola Friend! Looks like in your quest you have reached a location which does not exist yet.</h3>
<h4>To continue, either check your map location (URL) or go back <a href="{{ url_for('catalog.home') }}">home</a></h4>
</div>
{% endblock %}