Spaces:
Running
Running
File size: 482 Bytes
d0f5098 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
from fastapi import Request
from fastapi.exceptions import HTTPException
from fastapi.templating import Jinja2Templates
templates = Jinja2Templates(directory="templates")
class MyHTTPException(HTTPException):
pass
def my_http_exception_handler(request: Request, exc: HTTPException):
return templates.TemplateResponse(
"errors/error.html",
{"request": request, "message": f"{exc.status_code}. {exc.detail}."},
status_code=exc.status_code,
)
|