Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 20 for PlainTextResponse (0.23 sec)

  1. docs_src/handling_errors/tutorial004.py

    from fastapi.exceptions import RequestValidationError
    from fastapi.responses import PlainTextResponse
    from starlette.exceptions import HTTPException as StarletteHTTPException
    
    app = FastAPI()
    
    
    @app.exception_handler(StarletteHTTPException)
    async def http_exception_handler(request, exc):
        return PlainTextResponse(str(exc.detail), status_code=exc.status_code)
    
    
    @app.exception_handler(RequestValidationError)
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Thu Mar 26 19:09:53 UTC 2020
    - 762 bytes
    - Viewed (0)
  2. tests/test_tutorial/test_advanced_middleware/test_tutorial003.py

    from fastapi.responses import PlainTextResponse
    from fastapi.testclient import TestClient
    
    from docs_src.advanced_middleware.tutorial003 import app
    
    
    @app.get("/large")
    async def large():
        return PlainTextResponse("x" * 4000, status_code=200)
    
    
    client = TestClient(app)
    
    
    def test_middleware():
        response = client.get("/large", headers={"accept-encoding": "gzip"})
        assert response.status_code == 200, response.text
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Thu Jul 09 18:06:12 UTC 2020
    - 665 bytes
    - Viewed (0)
  3. tests/test_default_response_class.py

    
    @app.get("/")
    def get_root():
        return {"msg": "Hello World"}
    
    
    @app.get("/override", response_class=PlainTextResponse)
    def get_path_override():
        return "Hello World"
    
    
    @router_a.get("/")
    def get_a():
        return {"msg": "Hello A"}
    
    
    @router_a.get("/override", response_class=PlainTextResponse)
    def get_a_path_override():
        return "Hello A"
    
    
    @router_a_a.get("/")
    def get_a_a():
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sun Mar 01 20:49:20 UTC 2020
    - 5.2K bytes
    - Viewed (0)
  4. 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
    
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Thu Apr 18 19:53:19 UTC 2024
    - 3.7K bytes
    - Viewed (0)
  5. docs_src/custom_response/tutorial005.py

    from fastapi import FastAPI
    from fastapi.responses import PlainTextResponse
    
    app = FastAPI()
    
    
    @app.get("/", response_class=PlainTextResponse)
    async def main():
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Thu Mar 26 19:09:53 UTC 2020
    - 186 bytes
    - Viewed (0)
  6. tests/test_default_response_class_router.py

    
    @app.get("/")
    def get_root():
        return {"msg": "Hello World"}
    
    
    @app.get("/override", response_class=PlainTextResponse)
    def get_path_override():
        return "Hello World"
    
    
    @router_a.get("/")
    def get_a():
        return {"msg": "Hello A"}
    
    
    @router_a.get("/override", response_class=PlainTextResponse)
    def get_a_path_override():
        return "Hello A"
    
    
    @router_a_a.get("/")
    def get_a_a():
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sun Mar 01 20:49:20 UTC 2020
    - 5K bytes
    - Viewed (0)
  7. fastapi/responses.py

    from starlette.responses import HTMLResponse as HTMLResponse  # noqa
    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
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Wed Oct 18 12:36:40 UTC 2023
    - 1.7K bytes
    - Viewed (0)
  8. docs/em/docs/tutorial/handling-errors.md

    ๐Ÿ–ผ, ๐Ÿ‘† ๐Ÿ’ช ๐Ÿ’š ๐Ÿ“จ โœ… โœ ๐Ÿ“จ โ†ฉ๏ธ ๐ŸŽป ๐Ÿ‘ซ โŒ:
    
    ```Python hl_lines="3-4  9-11  22"
    {!../../docs_src/handling_errors/tutorial004.py!}
    ```
    
    /// note | "๐Ÿ“ก โ„น"
    
    ๐Ÿ‘† ๐Ÿ’ช โš™๏ธ `from starlette.responses import PlainTextResponse`.
    
    **FastAPI** ๐Ÿšš ๐ŸŽ `starlette.responses` `fastapi.responses` ๐Ÿช ๐Ÿ‘†, ๐Ÿ‘ฉโ€๐Ÿ’ป. โœ‹๏ธ ๐ŸŒ… ๐Ÿ’ช ๐Ÿ“จ ๐Ÿ‘Ÿ ๐Ÿ”— โšช๏ธโžก๏ธ ๐Ÿ’ƒ.
    
    ///
    
    ### โš™๏ธ `RequestValidationError` ๐Ÿ’ช
    
    `RequestValidationError` ๐Ÿ”Œ `body` โšซ๏ธ ๐Ÿ“จ โฎ๏ธ โŒ ๐Ÿ’ฝ.
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sun Oct 06 20:36:54 UTC 2024
    - 8.3K bytes
    - Viewed (0)
  9. docs/em/docs/advanced/custom-response.md

    ```Python hl_lines="1  18"
    {!../../docs_src/response_directly/tutorial002.py!}
    ```
    
    ### `HTMLResponse`
    
    โœŠ โœ โš–๏ธ ๐Ÿ”ข & ๐Ÿ“จ ๐Ÿ•ธ ๐Ÿ“จ, ๐Ÿ‘† โœ ๐Ÿ”›.
    
    ### `PlainTextResponse`
    
    โœŠ โœ โš–๏ธ ๐Ÿ”ข & ๐Ÿ“จ โœ… โœ ๐Ÿ“จ.
    
    ```Python hl_lines="2  7  9"
    {!../../docs_src/custom_response/tutorial005.py!}
    ```
    
    ### `JSONResponse`
    
    โœŠ ๐Ÿ’ฝ & ๐Ÿ“จ `application/json` ๐Ÿ—œ ๐Ÿ“จ.
    
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sun Oct 06 20:36:54 UTC 2024
    - 9.7K bytes
    - Viewed (0)
  10. docs/ja/docs/advanced/custom-response.md

    ```Python hl_lines="1  18"
    {!../../docs_src/response_directly/tutorial002.py!}
    ```
    
    ### `HTMLResponse`
    
    ไธŠใง่ชญใ‚“ใ ใ‚ˆใ†ใซใ€ใƒ†ใ‚ญใ‚นใƒˆใ‚„ใƒใ‚คใƒˆใ‚’ๅ—ใ‘ๅ–ใ‚Šใ€HTMLใƒฌใ‚นใƒใƒณใ‚นใ‚’่ฟ”ใ—ใพใ™ใ€‚
    
    ### `PlainTextResponse`
    
    ใƒ†ใ‚ญใ‚นใƒˆใ‚„ใƒใ‚คใƒˆใ‚’ๅ—ใ‘ๅ–ใ‚Šใ€ใƒ—ใƒฌใƒผใƒณใƒ†ใ‚ญใ‚นใƒˆใฎใƒฌใ‚นใƒใƒณใ‚นใ‚’่ฟ”ใ—ใพใ™ใ€‚
    
    ```Python hl_lines="2  7  9"
    {!../../docs_src/custom_response/tutorial005.py!}
    ```
    
    ### `JSONResponse`
    
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sun Oct 06 20:36:54 UTC 2024
    - 10.6K bytes
    - Viewed (0)
Back to top