diff --git a/truthinquiry/__init__.py b/truthinquiry/__init__.py index 91b276a..61abb15 100644 --- a/truthinquiry/__init__.py +++ b/truthinquiry/__init__.py @@ -10,7 +10,7 @@ from truthinquiry.ext.database import db from truthinquiry.ext.socketio import socket_io from truthinquiry.ext.discord_bot import discord_bot -from truthinquiry.routes import routes_api, routes_ui, routes_socketio +from truthinquiry.routes import routes_api, routes_ui, routes_socketio, handlers def register_extensions(app): db.init_app(app) @@ -31,4 +31,6 @@ def create_app(): register_routes(app) + handlers.register_handlers(app) + return app diff --git a/truthinquiry/routes/handlers.py b/truthinquiry/routes/handlers.py new file mode 100644 index 0000000..1657cce --- /dev/null +++ b/truthinquiry/routes/handlers.py @@ -0,0 +1,12 @@ + +import flask +from werkzeug.exceptions import HTTPException + +def http_error_handler(e): + return flask.render_template( + "errorhandler.html", + desc=e.description, + url=f"https://http.cat/{e.code}"), e.code + +def register_handlers(app): + app.errorhandler(HTTPException)(http_error_handler) diff --git a/truthinquiry/templates/errorhandler.html b/truthinquiry/templates/errorhandler.html new file mode 100644 index 0000000..843124c --- /dev/null +++ b/truthinquiry/templates/errorhandler.html @@ -0,0 +1,2 @@ + +

{{desc}}