Вот как я создаю простой проект
from flask import Blueprint, render_template
my_bp_page = Blueprint('my_bp_page', __name__, template_folder='templates')
@my_bp_page.errorhandler(404)
def page_not_found(e):
return render_template('404.html', pageName='my_bp_page.home')
@my_bp_page.route('/home', methods=['GET'], strict_slashes=False)
def home():
return render_template('home.html')
, а вот мой 404.html
{% block title %}Page Not Found{% endblock %}
{% block body %}
<h1>Page Not Found</h1>
<p>What you were looking for is just not there.
<p>
{% if pageName is defined %}
<a href="{{ url_for(pageName) }}">Go Back</a>
{% else %}
<a href="{{ url_for('home') }}">Go Back</a>
{% endif %}
{% endblock %}
при тестировании, я попробовал URL localhost:5000/home/junk
, и ясм.
Not Found
The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.
это не то, что я должен видеть. Я должен видеть мой заказ 404.html
Что я делаю не так?