diff options
-rw-r--r-- | apioforum/__init__.py | 9 | ||||
-rw-r--r-- | apioforum/templates/err/403.html | 8 | ||||
-rw-r--r-- | apioforum/templates/err/404.html | 8 |
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 %} |