Files
alfieking.dev/src/errors.py
Alfie King af5116d931
All checks were successful
Deploy website / deploy (push) Successful in 2m1s
update idk
2026-03-29 15:50:47 +01:00

38 lines
988 B
Python

from flask import Blueprint, render_template
from werkzeug.exceptions import HTTPException
bp = Blueprint("errors", __name__)
@bp.route('/500')
@bp.app_errorhandler(500)
def internal_server_error(error:HTTPException=None):
return render_template('errors/500.html', error=error), 500
@bp.route('/404')
@bp.app_errorhandler(404)
def not_found(error:HTTPException=None):
return render_template('errors/404.html', error=error), 404
@bp.route('/400')
@bp.app_errorhandler(400)
def bad_request(error:HTTPException=None):
return render_template('errors/400.html', error=error), 400
@bp.route('/idk')
@bp.app_errorhandler(Exception)
def idk(error:HTTPException=None):
if not isinstance(error, HTTPException):
error = HTTPException("I honestly dont know")
error.code = 418
return render_template(
'errors/error.html',
code = error.code,
description = error.description,
err_name = error.name,
), error.code