Merge pull request #77 from ThomasRubini/err_handler

This commit is contained in:
Thomas Rubini 2023-02-16 09:24:14 +01:00 committed by GitHub
commit 7b3b2c868d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 1 deletions

View File

@ -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

View File

@ -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)

View File

@ -0,0 +1,2 @@
<img src="{{url}}">
<p> {{desc}} </p>