Search Options

Display Count
Sort
Preferred Language
Advanced Search

Results 341 - 350 of 1,531 for Responses (0.13 seconds)

The search processing time has exceeded the limit. The displayed results may be partial.

  1. docs_src/custom_response/tutorial010_py310.py

    from fastapi import FastAPI
    from fastapi.responses import HTMLResponse
    
    app = FastAPI(default_response_class=HTMLResponse)
    
    
    @app.get("/items/")
    async def read_items():
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Sun Feb 22 16:07:19 GMT 2026
    - 228 bytes
    - Click Count (0)
  2. tests/test_tutorial/test_additional_responses/test_tutorial002.py

    def test_path_operation(client: TestClient):
        response = client.get("/items/foo")
        assert response.status_code == 200, response.text
        assert response.json() == {"id": "foo", "value": "there goes my hero"}
    
    
    @workdir_lock
    def test_path_operation_img(client: TestClient):
        shutil.copy("./docs/en/docs/img/favicon.png", "./image.png")
        response = client.get("/items/foo?img=1")
        assert response.status_code == 200, response.text
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Fri Feb 27 10:53:47 GMT 2026
    - 5.3K bytes
    - Click Count (0)
  3. docs_src/custom_response/tutorial002_py310.py

    from fastapi import FastAPI
    from fastapi.responses import HTMLResponse
    
    app = FastAPI()
    
    
    @app.get("/items/", response_class=HTMLResponse)
    async def read_items():
        return """
        <html>
            <head>
                <title>Some HTML in here</title>
            </head>
            <body>
                <h1>Look ma! HTML!</h1>
            </body>
        </html>
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Thu Feb 12 13:19:43 GMT 2026
    - 352 bytes
    - Click Count (0)
  4. docs_src/custom_response/tutorial007_py310.py

    import anyio
    from fastapi import FastAPI
    from fastapi.responses import StreamingResponse
    
    app = FastAPI()
    
    
    async def fake_video_streamer():
        for i in range(10):
            yield b"some fake video bytes"
            await anyio.sleep(0)
    
    
    @app.get("/")
    async def main():
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Fri Feb 27 19:12:46 GMT 2026
    - 319 bytes
    - Click Count (0)
  5. docs_src/custom_response/tutorial008_py310.py

    from fastapi import FastAPI
    from fastapi.responses import StreamingResponse
    
    some_file_path = "large-video-file.mp4"
    app = FastAPI()
    
    
    @app.get("/")
    def main():
        def iterfile():  # (1)
            with open(some_file_path, mode="rb") as file_like:  # (2)
                yield from file_like  # (3)
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Thu Feb 12 13:19:43 GMT 2026
    - 360 bytes
    - Click Count (0)
  6. tests/test_tutorial/test_behind_a_proxy/test_tutorial002.py

    client = TestClient(app)
    
    
    def test_main():
        response = client.get("/app")
        assert response.status_code == 200
        assert response.json() == {"message": "Hello World", "root_path": "/api/v1"}
    
    
    def test_openapi():
        response = client.get("/openapi.json")
        assert response.status_code == 200
        assert response.json() == snapshot(
            {
                "openapi": "3.1.0",
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Thu Feb 12 13:19:43 GMT 2026
    - 1.1K bytes
    - Click Count (0)
  7. tests/test_deprecated_responses.py

        app = _make_orjson_app()
        client = TestClient(app)
        with warnings.catch_warnings():
            warnings.simplefilter("ignore", FastAPIDeprecationWarning)
            response = client.get("/items")
        assert response.status_code == 200
        assert response.json() == {"name": "widget", "price": 9.99}
    
    
    def test_orjson_response_emits_deprecation_warning():
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Sun Feb 22 16:34:59 GMT 2026
    - 2K bytes
    - Click Count (0)
  8. tests/test_tutorial/test_body/test_tutorial003.py

                },
            ]
        }
    
    
    def test_openapi_schema(client: TestClient):
        response = client.get("/openapi.json")
        assert response.status_code == 200, response.text
        assert response.json() == snapshot(
            {
                "openapi": "3.1.0",
                "info": {"title": "FastAPI", "version": "0.1.0"},
                "paths": {
                    "/items/{item_id}": {
                        "put": {
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Thu Feb 12 13:19:43 GMT 2026
    - 6.1K bytes
    - Click Count (0)
  9. tests/test_put_no_body.py

    client = TestClient(app)
    
    
    def test_put_no_body():
        response = client.put("/items/foo")
        assert response.status_code == 200, response.text
        assert response.json() == {"item_id": "foo"}
    
    
    def test_put_no_body_with_body():
        response = client.put("/items/foo", json={"name": "Foo"})
        assert response.status_code == 200, response.text
        assert response.json() == {"item_id": "foo"}
    
    
    def test_openapi_schema():
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Sun Feb 08 10:18:38 GMT 2026
    - 3.8K bytes
    - Click Count (0)
  10. docs_src/additional_status_codes/tutorial001_an_py310.py

    from typing import Annotated
    
    from fastapi import Body, FastAPI, status
    from fastapi.responses import JSONResponse
    
    app = FastAPI()
    
    items = {"foo": {"name": "Fighters", "size": 6}, "bar": {"name": "Tenders", "size": 3}}
    
    
    @app.put("/items/{item_id}")
    async def upsert_item(
        item_id: str,
        name: Annotated[str | None, Body()] = None,
        size: Annotated[int | None, Body()] = None,
    ):
        if item_id in items:
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Sat Mar 18 12:29:59 GMT 2023
    - 686 bytes
    - Click Count (0)
Back to Top