add home link to error page and catch missing template exception in glob route

This commit is contained in:
dandds 2018-10-31 13:41:04 -04:00
parent 87baa1f873
commit 0a176239b7
2 changed files with 10 additions and 1 deletions

View File

@ -2,6 +2,7 @@ import urllib.parse as url
from flask import Blueprint, render_template, g, redirect, session, url_for, request from flask import Blueprint, render_template, g, redirect, session, url_for, request
from flask import current_app as app from flask import current_app as app
from jinja2.exceptions import TemplateNotFound
import pendulum import pendulum
import os import os
@ -10,6 +11,7 @@ from atst.domain.users import Users
from atst.domain.authnid import AuthenticationContext from atst.domain.authnid import AuthenticationContext
from atst.domain.audit_log import AuditLog from atst.domain.audit_log import AuditLog
from atst.domain.auth import logout as _logout from atst.domain.auth import logout as _logout
from werkzeug.exceptions import NotFound
bp = Blueprint("atst", __name__) bp = Blueprint("atst", __name__)
@ -77,7 +79,10 @@ def styleguide():
@bp.route("/<path:path>") @bp.route("/<path:path>")
def catch_all(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(): def _make_authentication_context():

View File

@ -10,6 +10,10 @@
<h1>An error occurred.</h1> <h1>An error occurred.</h1>
{% endif %} {% endif %}
{% if g.current_user %}
<p>Return <a href="{{ url_for("atst.home") }}">home</a>.</p>
{% endif %}
</main> </main>
{% endblock %} {% endblock %}