Search Options

Display Count
Sort
Preferred Language
Advanced Search

Results 151 - 160 of 445 for item_1 (0.31 seconds)

  1. docs/fr/docs/index.md

    app = FastAPI()
    
    
    class Item(BaseModel):
        name: str
        price: float
        is_offer: bool | None = None
    
    
    @app.get("/")
    def read_root():
        return {"Hello": "World"}
    
    
    @app.get("/items/{item_id}")
    def read_item(item_id: int, q: str | None = None):
        return {"item_id": item_id, "q": q}
    
    
    @app.put("/items/{item_id}")
    def update_item(item_id: int, item: Item):
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Thu Mar 19 18:37:13 GMT 2026
    - 23.8K bytes
    - Click Count (0)
  2. docs_src/schema_extra_example/tutorial005_an_py310.py

    from fastapi import Body, FastAPI
    from pydantic import BaseModel
    
    app = FastAPI()
    
    
    class Item(BaseModel):
        name: str
        description: str | None = None
        price: float
        tax: float | None = None
    
    
    @app.put("/items/{item_id}")
    async def update_item(
        *,
        item_id: int,
        item: Annotated[
            Item,
            Body(
                openapi_examples={
                    "normal": {
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Sat Aug 26 18:03:13 GMT 2023
    - 1.5K bytes
    - Click Count (0)
  3. docs_src/query_params_str_validations/tutorial008_py310.py

    from fastapi import FastAPI, Query
    
    app = FastAPI()
    
    
    @app.get("/items/")
    async def read_items(
        q: str | None = Query(
            default=None,
            title="Query string",
            description="Query string for the items to search in the database that have a good match",
            min_length=3,
        ),
    ):
        results = {"items": [{"item_id": "Foo"}, {"item_id": "Bar"}]}
        if q:
            results.update({"q": q})
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Tue Oct 24 20:26:06 GMT 2023
    - 434 bytes
    - Click Count (0)
  4. docs_src/app_testing/tutorial004_py310.py

    from fastapi.testclient import TestClient
    
    items = {}
    
    
    @asynccontextmanager
    async def lifespan(app: FastAPI):
        items["foo"] = {"name": "Fighters"}
        items["bar"] = {"name": "Tenders"}
        yield
        # clean up items
        items.clear()
    
    
    app = FastAPI(lifespan=lifespan)
    
    
    @app.get("/items/{item_id}")
    async def read_items(item_id: str):
        return items[item_id]
    
    
    def test_read_items():
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Thu Feb 12 13:19:43 GMT 2026
    - 1.2K bytes
    - Click Count (0)
  5. docs_src/app_testing/app_b_py310/main.py

        return fake_db[item_id]
    
    
    @app.post("/items/")
    async def create_item(item: Item, x_token: str = Header()) -> Item:
        if x_token != fake_secret_token:
            raise HTTPException(status_code=400, detail="Invalid X-Token header")
        if item.id in fake_db:
            raise HTTPException(status_code=409, detail="Item already exists")
        fake_db[item.id] = item.model_dump()
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Wed Feb 04 13:32:24 GMT 2026
    - 1.1K bytes
    - Click Count (0)
  6. README.md

    app = FastAPI()
    
    
    class Item(BaseModel):
        name: str
        price: float
        is_offer: bool | None = None
    
    
    @app.get("/")
    def read_root():
        return {"Hello": "World"}
    
    
    @app.get("/items/{item_id}")
    def read_item(item_id: int, q: str | None = None):
        return {"item_id": item_id, "q": q}
    
    
    @app.put("/items/{item_id}")
    def update_item(item_id: int, item: Item):
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Sat Mar 07 09:29:03 GMT 2026
    - 24.3K bytes
    - Click Count (0)
  7. docs/zh-hant/docs/index.md

    使用瀏覽器開啟 [http://127.0.0.1:8000/items/5?q=somequery](http://127.0.0.1:8000/items/5?q=somequery)。
    
    你將會看到以下 JSON 回應:
    
    ```JSON
    {"item_id": 5, "q": "somequery"}
    ```
    
    你已經建立了一個具有以下功能的 API:
    
    * 透過路徑 `/` 和 `/items/{item_id}` 接受 HTTP 請求。
    * 以上兩個路徑都接受 `GET` 操作(也被稱為 HTTP _方法_)。
    * 路徑 `/items/{item_id}` 有一個 `int` 型別的路徑參數 `item_id`。
    * 路徑 `/items/{item_id}` 有一個可選的 `str` 查詢參數 `q`。
    
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Fri Mar 20 17:05:38 GMT 2026
    - 20.8K bytes
    - Click Count (0)
  8. fastapi/exceptions.py

        ```python
        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")
            return {"item": items[item_id]}
        ```
        """
    
        def __init__(
            self,
            status_code: Annotated[
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Wed Feb 11 18:41:21 GMT 2026
    - 7.3K bytes
    - Click Count (0)
  9. docs_src/query_params_str_validations/tutorial001_py310.py

    from fastapi import FastAPI
    
    app = FastAPI()
    
    
    @app.get("/items/")
    async def read_items(q: str | None = None):
        results = {"items": [{"item_id": "Foo"}, {"item_id": "Bar"}]}
        if q:
            results.update({"q": q})
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Fri Jan 07 14:11:31 GMT 2022
    - 239 bytes
    - Click Count (0)
  10. docs_src/query_params_str_validations/tutorial006_py310.py

    from fastapi import FastAPI, Query
    
    app = FastAPI()
    
    
    @app.get("/items/")
    async def read_items(q: str = Query(min_length=3)):
        results = {"items": [{"item_id": "Foo"}, {"item_id": "Bar"}]}
        if q:
            results.update({"q": q})
    Created: Sun Apr 05 07:19:11 GMT 2026
    - Last Modified: Thu Feb 12 13:19:43 GMT 2026
    - 254 bytes
    - Click Count (0)
Back to Top