[Python] How to return a custom 404 Not Found page using FastAPI?

Discussão em 'Python' iniciado por Stack, Junho 6, 2025.

  1. Stack

    Stack Membro Participativo

    I am making a rick roll site for Discord and I would like to redirect to the rick roll page on 404 response status codes.

    I've tried the following, but didn't work:

    @app.exception_handler(fastapi.HTTPException)
    async def http_exception_handler(request, exc):
    ...

    Continue reading...

Compartilhe esta Página