Merge pull request #77 from ThomasRubini/err_handler
This commit is contained in:
		
						commit
						7b3b2c868d
					
				@ -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
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										12
									
								
								truthinquiry/routes/handlers.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								truthinquiry/routes/handlers.py
									
									
									
									
									
										Normal 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)
 | 
			
		||||
							
								
								
									
										2
									
								
								truthinquiry/templates/errorhandler.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								truthinquiry/templates/errorhandler.html
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,2 @@
 | 
			
		||||
<img src="{{url}}">
 | 
			
		||||
<p> {{desc}} </p>
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user