From 0a176239b73c1f5fdf09e2310b45c1fa7daee275 Mon Sep 17 00:00:00 2001 From: dandds Date: Wed, 31 Oct 2018 13:41:04 -0400 Subject: [PATCH] add home link to error page and catch missing template exception in glob route --- atst/routes/__init__.py | 7 ++++++- templates/error.html | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/atst/routes/__init__.py b/atst/routes/__init__.py index 0149ace5..780ff0c3 100644 --- a/atst/routes/__init__.py +++ b/atst/routes/__init__.py @@ -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("/") 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(): diff --git a/templates/error.html b/templates/error.html index c8714c01..f58eac86 100644 --- a/templates/error.html +++ b/templates/error.html @@ -10,6 +10,10 @@

An error occurred.

{% endif %} +{% if g.current_user %} +

Return home.

+{% endif %} + {% endblock %}