aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorubq323 <ubq323>2021-11-06 17:48:02 +0000
committerubq323 <ubq323>2021-11-06 17:48:02 +0000
commit828aa456e72bcaf6e46d5fd17792f08d4dcfc62f (patch)
treee687033ef10eddd39dd98c8d780c1c01a77f33be
parent00e0b45a731a6de8dff4106ec8686d70189ca182 (diff)
404 and 403 pages now use main layout
-rw-r--r--apioforum/__init__.py9
-rw-r--r--apioforum/templates/err/403.html8
-rw-r--r--apioforum/templates/err/404.html8
3 files changed, 24 insertions, 1 deletions
diff --git a/apioforum/__init__.py b/apioforum/__init__.py
index b9077a2..2b49066 100644
--- a/apioforum/__init__.py
+++ b/apioforum/__init__.py
@@ -1,7 +1,7 @@
# boilerplate boilerplate boilerplate
# yay
-from flask import Flask, request, session
+from flask import Flask, request, session, render_template
from .db import get_db
import os
@@ -65,6 +65,13 @@ def create_app():
def md_render(s):
return render(s)
+ @app.errorhandler(404)
+ def not_found(e):
+ return render_template('err/404.html'), 404
+ @app.errorhandler(403)
+ def forbidden(e):
+ return render_template('err/403.html'), 403
+
app.add_url_rule("/",endpoint="index")
return app
diff --git a/apioforum/templates/err/403.html b/apioforum/templates/err/403.html
new file mode 100644
index 0000000..bae6857
--- /dev/null
+++ b/apioforum/templates/err/403.html
@@ -0,0 +1,8 @@
+{% extends 'base.html' %}
+{% block header %}
+<h1>{% block title %}403 forbidden{% endblock %}</h1>
+{% endblock %}
+
+{% block content %}
+<p>you don't have permission to access the requested page</p>
+{% endblock %}
diff --git a/apioforum/templates/err/404.html b/apioforum/templates/err/404.html
new file mode 100644
index 0000000..5b0030e
--- /dev/null
+++ b/apioforum/templates/err/404.html
@@ -0,0 +1,8 @@
+{% extends 'base.html' %}
+{% block header %}
+<h1>{% block title %}404 not found{% endblock %}</h1>
+{% endblock %}
+
+{% block content %}
+<p>the requested url was not found on the server. if you entered the url manually please check your spelling and try again</p>
+{% endblock %}