Search Options

Display Count
Sort
Preferred Language
Advanced Search

Results 1 - 10 of 34 for RedirectResponse (0.11 seconds)

  1. docs_src/custom_response/tutorial006_py310.py

    from fastapi import FastAPI
    from fastapi.responses import RedirectResponse
    
    app = FastAPI()
    
    
    @app.get("/typer")
    async def redirect_typer():
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Thu Feb 12 13:19:43 GMT 2026
    - 199 bytes
    - Click Count (0)
  2. docs_src/response_model/tutorial003_03_py310.py

    from fastapi import FastAPI
    from fastapi.responses import RedirectResponse
    
    app = FastAPI()
    
    
    @app.get("/teleport")
    async def get_teleport() -> RedirectResponse:
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Thu Feb 12 13:19:43 GMT 2026
    - 241 bytes
    - Click Count (0)
  3. docs_src/custom_response/tutorial006c_py310.py

    from fastapi import FastAPI
    from fastapi.responses import RedirectResponse
    
    app = FastAPI()
    
    
    @app.get("/pydantic", response_class=RedirectResponse, status_code=302)
    async def redirect_pydantic():
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Thu Feb 12 13:19:43 GMT 2026
    - 237 bytes
    - Click Count (0)
  4. docs_src/response_model/tutorial003_02_py310.py

    from fastapi import FastAPI, Response
    from fastapi.responses import JSONResponse, RedirectResponse
    
    app = FastAPI()
    
    
    @app.get("/portal")
    async def get_portal(teleport: bool = False) -> Response:
        if teleport:
            return RedirectResponse(url="https://www.youtube.com/watch?v=dQw4w9WgXcQ")
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Thu Feb 12 13:19:43 GMT 2026
    - 381 bytes
    - Click Count (0)
  5. docs/en/docs/advanced/custom-response.md

    This is the ideal way to get the best performance.
    
    ///
    
    ### `RedirectResponse` { #redirectresponse }
    
    Returns an HTTP redirect. Uses a 307 status code (Temporary Redirect) by default.
    
    You can return a `RedirectResponse` directly:
    
    {* ../../docs_src/custom_response/tutorial006_py310.py hl[2,9] *}
    
    ---
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Thu Mar 05 18:13:19 GMT 2026
    - 11K bytes
    - Click Count (0)
  6. fastapi/responses.py

    from starlette.responses import JSONResponse as JSONResponse  # noqa
    from starlette.responses import PlainTextResponse as PlainTextResponse  # noqa
    from starlette.responses import RedirectResponse as RedirectResponse  # noqa
    from starlette.responses import Response as Response  # noqa
    from starlette.responses import StreamingResponse as StreamingResponse  # noqa
    from typing_extensions import deprecated
    
    try:
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Sun Mar 01 09:21:52 GMT 2026
    - 3.6K bytes
    - Click Count (0)
  7. docs/en/docs/reference/responses.md

    You can import them directly from `fastapi.responses`:
    
    ```python
    from fastapi.responses import (
        FileResponse,
        HTMLResponse,
        JSONResponse,
        ORJSONResponse,
        PlainTextResponse,
        RedirectResponse,
        Response,
        StreamingResponse,
        UJSONResponse,
    )
    ```
    
    ## FastAPI Responses
    
    There were a couple of custom FastAPI response classes that were intended to optimize JSON performance.
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Sun Feb 22 16:34:59 GMT 2026
    - 4.4K bytes
    - Click Count (0)
  8. docs/zh-hant/docs/advanced/custom-response.md

    /// note | 技術細節
    
    但如果你宣告了回應模型或回傳型別,將會直接用它來把資料序列化為 JSON,並直接回傳具有正確 JSON media type 的回應,而不會使用 `JSONResponse` 類別。
    
    這是取得最佳效能的理想方式。
    
    ///
    
    ### `RedirectResponse` { #redirectresponse }
    
    回傳一個 HTTP 重新導向。預設使用 307 狀態碼(Temporary Redirect)。
    
    你可以直接回傳 `RedirectResponse`:
    
    {* ../../docs_src/custom_response/tutorial006_py310.py hl[2,9] *}
    
    ---
    
    或者你可以在 `response_class` 參數中使用它:
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Fri Mar 20 17:05:38 GMT 2026
    - 10.3K bytes
    - Click Count (0)
  9. docs/en/docs/tutorial/response-model.md

    And tools will also be happy because both `RedirectResponse` and `JSONResponse` are subclasses of `Response`, so the type annotation is correct.
    
    ### Annotate a Response Subclass { #annotate-a-response-subclass }
    
    You can also use a subclass of `Response` in the type annotation:
    
    {* ../../docs_src/response_model/tutorial003_03_py310.py hl[8:9] *}
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Thu Mar 05 18:13:19 GMT 2026
    - 15.5K bytes
    - Click Count (0)
  10. fastapi/routing.py

                    Read more about it in the
                    [FastAPI docs for Custom Response - HTML, Stream, File, others](https://fastapi.tiangolo.com/advanced/custom-response/#redirectresponse).
                    """
                ),
            ] = Default(JSONResponse),
            name: Annotated[
                str | None,
                Doc(
                    """
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Sun Mar 15 11:44:39 GMT 2026
    - 193K bytes
    - Click Count (0)
Back to Top