From 828aa456e72bcaf6e46d5fd17792f08d4dcfc62f Mon Sep 17 00:00:00 2001 From: ubq323 Date: Sat, 6 Nov 2021 17:48:02 +0000 Subject: 404 and 403 pages now use main layout --- apioforum/__init__.py | 9 ++++++++- apioforum/templates/err/403.html | 8 ++++++++ apioforum/templates/err/404.html | 8 ++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 apioforum/templates/err/403.html create mode 100644 apioforum/templates/err/404.html 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 %} +

{% block title %}403 forbidden{% endblock %}

+{% endblock %} + +{% block content %} +

you don't have permission to access the requested page

+{% 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 %} +

{% block title %}404 not found{% endblock %}

+{% endblock %} + +{% block content %} +

the requested url was not found on the server. if you entered the url manually please check your spelling and try again

+{% endblock %} -- cgit v1.2.3