[Python] How to add body content to FastAPI's RedirectResponse?

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

  1. Stack

    Stack Membro Participativo

    I would like to use an audio file inside the /check_base endpoint in the example below. However, I can't send the file in FastAPI's RedirectResponse body. The /check endpoint returns a RedirectResponse, which only accepts a URL parameter.

    Here is my code:

    @router.post("/check")
    async def check(
    request: Request
    ):
    file = StarletteUploadFile(filename="/home/hello.wav")
    redirect_url = app.url_path_for("check_base", **{'audio':file)

    response = RedirectResponse(url=redirect_url)
    return response


    @router.post("/check_base")
    async def check_base(
    request: Request,
    audio: UploadFile = File(...)
    ):

    Continue reading...

Compartilhe esta Página