add home link to error page and catch missing template exception in glob route
This commit is contained in:
parent
87baa1f873
commit
0a176239b7
@ -2,6 +2,7 @@ import urllib.parse as url
|
||||
from flask import Blueprint, render_template, g, redirect, session, url_for, request
|
||||
|
||||
from flask import current_app as app
|
||||
from jinja2.exceptions import TemplateNotFound
|
||||
import pendulum
|
||||
import os
|
||||
|
||||
@ -10,6 +11,7 @@ from atst.domain.users import Users
|
||||
from atst.domain.authnid import AuthenticationContext
|
||||
from atst.domain.audit_log import AuditLog
|
||||
from atst.domain.auth import logout as _logout
|
||||
from werkzeug.exceptions import NotFound
|
||||
|
||||
|
||||
bp = Blueprint("atst", __name__)
|
||||
@ -77,7 +79,10 @@ def styleguide():
|
||||
|
||||
@bp.route("/<path:path>")
|
||||
def catch_all(path):
|
||||
return render_template("{}.html".format(path))
|
||||
try:
|
||||
return render_template("{}.html".format(path))
|
||||
except TemplateNotFound:
|
||||
raise NotFound()
|
||||
|
||||
|
||||
def _make_authentication_context():
|
||||
|
@ -10,6 +10,10 @@
|
||||
<h1>An error occurred.</h1>
|
||||
{% endif %}
|
||||
|
||||
{% if g.current_user %}
|
||||
<p>Return <a href="{{ url_for("atst.home") }}">home</a>.</p>
|
||||
{% endif %}
|
||||
|
||||
</main>
|
||||
|
||||
{% endblock %}
|
||||
|
Loading…
x
Reference in New Issue
Block a user