30 lines
1.3 KiB
Python
30 lines
1.3 KiB
Python
from flask import Flask, render_template
|
|
|
|
|
|
def register_errorhandlers(app: Flask) -> None:
|
|
@app.errorhandler(400)
|
|
def bad_request(e) -> tuple:
|
|
content: dict = {'title': 'Bad Request',
|
|
'content': [('HTTP Status 400', 'The request is malformed and cannot be processed.')]}
|
|
return render_template('generic.html', **content), 400
|
|
|
|
@app.errorhandler(404)
|
|
def not_found(e) -> tuple:
|
|
content: dict = {'title': 'Not Found',
|
|
'content': [('HTTP Status 404', 'The requsted ressource was not found.')]}
|
|
return render_template('generic.html', **content), 404
|
|
|
|
@app.errorhandler(405)
|
|
def method_not_allowed(e) -> tuple:
|
|
content: dict = {'title': 'Method Not Allowed',
|
|
'content': [('HTTP Status 405', 'The requested method is not allowed for this ressource.')]}
|
|
return render_template('generic.html', **content), 405
|
|
|
|
@app.errorhandler(500)
|
|
def internal_server_error(e) -> tuple:
|
|
content: dict = {'title': 'Internal Server Error',
|
|
'content': [('HTTP Status 500', 'The request cannot be answered due to an internal server error.')]}
|
|
return render_template('generic.html', **content), 500
|
|
|
|
return
|