Search Options

Results per page
Sort
Preferred Languages
Advance

Results 11 - 20 of 274 for head_item (0.06 sec)

  1. docs_src/additional_responses/tutorial001_py39.py

        id: str
        value: str
    
    
    class Message(BaseModel):
        message: str
    
    
    app = FastAPI()
    
    
    @app.get("/items/{item_id}", response_model=Item, responses={404: {"model": Message}})
    async def read_item(item_id: str):
        if item_id == "foo":
            return {"id": "foo", "value": "there goes my hero"}
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Dec 17 20:41:43 UTC 2025
    - 506 bytes
    - Viewed (0)
  2. tests/test_additional_response_extra.py

    from fastapi import APIRouter, FastAPI
    from fastapi.testclient import TestClient
    
    router = APIRouter()
    
    sub_router = APIRouter()
    
    app = FastAPI()
    
    
    @sub_router.get("/")
    def read_item():
        return {"id": "foo"}
    
    
    router.include_router(sub_router, prefix="/items")
    
    app.include_router(router)
    
    client = TestClient(app)
    
    
    def test_path_operation():
        response = client.get("/items/")
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Fri Jun 30 18:25:16 UTC 2023
    - 1.2K bytes
    - Viewed (0)
  3. docs_src/path_params/tutorial001_py39.py

    from fastapi import FastAPI
    
    app = FastAPI()
    
    
    @app.get("/items/{item_id}")
    async def read_item(item_id):
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Dec 17 20:41:43 UTC 2025
    - 138 bytes
    - Viewed (0)
  4. docs_src/additional_responses/tutorial004_py310.py

    }
    
    
    app = FastAPI()
    
    
    @app.get(
        "/items/{item_id}",
        response_model=Item,
        responses={**responses, 200: {"content": {"image/png": {}}}},
    )
    async def read_item(item_id: str, img: bool | None = None):
        if img:
            return FileResponse("image.png", media_type="image/png")
        else:
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Dec 10 08:55:32 UTC 2025
    - 669 bytes
    - Viewed (0)
  5. docs/zh/docs/advanced/templates.md

    ```html
    Item ID: 42
    ```
    
    ### 模板 `url_for` 参数
    
    你还可以在模板内使用 `url_for()`,其参数与*路径操作函数*的参数相同.
    
    所以,该部分:
    
    {% raw %}
    
    ```jinja
    <a href="{{ url_for('read_item', id=id) }}">
    ```
    
    {% endraw %}
    
    ...将生成一个与处理*路径操作函数* `read_item(id=id)`的URL相同的链接
    
    例如。当ID为 `42`时, 会渲染成:
    
    ```html
    <a href="/items/42">
    ```
    
    ## 模板与静态文件
    
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Oct 11 17:48:49 UTC 2025
    - 2.7K bytes
    - Viewed (0)
  6. docs_src/body_updates/tutorial002_py310.py

        "baz": {"name": "Baz", "description": None, "price": 50.2, "tax": 10.5, "tags": []},
    }
    
    
    @app.get("/items/{item_id}", response_model=Item)
    async def read_item(item_id: str):
        return items[item_id]
    
    
    @app.patch("/items/{item_id}", response_model=Item)
    async def update_item(item_id: str, item: Item):
        stored_item_data = items[item_id]
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Dec 20 15:55:38 UTC 2025
    - 1022 bytes
    - Viewed (0)
  7. docs_src/additional_responses/tutorial003_py39.py

                "content": {
                    "application/json": {
                        "example": {"id": "bar", "value": "The bar tenders"}
                    }
                },
            },
        },
    )
    async def read_item(item_id: str):
        if item_id == "foo":
            return {"id": "foo", "value": "there goes my hero"}
        else:
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Dec 17 20:41:43 UTC 2025
    - 837 bytes
    - Viewed (0)
  8. docs_src/handling_errors/tutorial004_py39.py

        for error in exc.errors():
            message += f"\nField: {error['loc']}, Error: {error['msg']}"
        return PlainTextResponse(message, status_code=400)
    
    
    @app.get("/items/{item_id}")
    async def read_item(item_id: int):
        if item_id == 3:
            raise HTTPException(status_code=418, detail="Nope! I don't like 3.")
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Dec 17 20:41:43 UTC 2025
    - 920 bytes
    - Viewed (0)
  9. docs_src/handling_errors/tutorial001_py39.py

    from fastapi import FastAPI, HTTPException
    
    app = FastAPI()
    
    items = {"foo": "The Foo Wrestlers"}
    
    
    @app.get("/items/{item_id}")
    async def read_item(item_id: str):
        if item_id not in items:
            raise HTTPException(status_code=404, detail="Item not found")
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Dec 17 20:41:43 UTC 2025
    - 299 bytes
    - Viewed (0)
  10. docs/en/docs/advanced/templates.md

    So, the section with:
    
    {% raw %}
    
    ```jinja
    <a href="{{ url_for('read_item', id=id) }}">
    ```
    
    {% endraw %}
    
    ...will generate a link to the same URL that would be handled by the *path operation function* `read_item(id=id)`.
    
    For example, with an ID of `42`, this would render:
    
    ```html
    <a href="/items/42">
    ```
    
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Dec 17 20:41:43 UTC 2025
    - 3.5K bytes
    - Viewed (0)
Back to top