summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMorgana <Morgana@icolotl.com>2026-10-05 19:41:04 -0500
committerMorgana <Morgana@icolotl.com>2026-10-05 19:41:04 -0500
commitaf184aa3e2a8a71a2357669affe091e8e275a2bd (patch)
tree12664aac091707f5dc0997e126584765ca9402e3
parentb1c52340d1a615eba11f921bfb6893024af6b3d7 (diff)
Implement basic error page
-rw-r--r--app.py13
-rw-r--r--templates/error.html8
2 files changed, 17 insertions, 4 deletions
diff --git a/app.py b/app.py
index 7d93b4f..353de94 100644
--- a/app.py
+++ b/app.py
@@ -70,7 +70,7 @@ def context_processor():
@app.before_request
def before_request():
- if request.endpoint == "static":
+ if not request.endpoint or request.endpoint == "static":
return
db = get_db()
cur = db.cursor()
@@ -104,9 +104,14 @@ def before_request():
@app.errorhandler(HTTPException)
-def handle_bad_request(e):
- # TODO: Create an actual error page.
- return e
+def handle_bad_request(error):
+ if error.code == 501:
+ if "username" in session:
+ flash("This content requires additional permissions to view.")
+ else:
+ flash("You must be logged in to access this content.")
+ return redirect(url_for("login"))
+ return render_template("error.html", error=error), error.code
@app.route("/")
diff --git a/templates/error.html b/templates/error.html
new file mode 100644
index 0000000..d7f3218
--- /dev/null
+++ b/templates/error.html
@@ -0,0 +1,8 @@
+{% extends "base.html" %}
+
+{% block content %}
+<main class="centered">
+ <h2>Error {{ error.code }}: {{ error.name }}</h2>
+ <a href="/">Return to the Main Page</a>
+</main>
+{% endblock %} \ No newline at end of file