Search Options

Results per page
Sort
Preferred Languages
Advance

Results 41 - 50 of 540 for item_b (0.03 sec)

  1. docs_src/app_testing/app_b_py310/main.py

        return fake_db[item_id]
    
    
    @app.post("/items/", response_model=Item)
    async def create_item(item: Item, x_token: str = Header()):
        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
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Tue Jan 09 14:44:08 UTC 2024
    - 1.1K bytes
    - Viewed (0)
  2. docs_src/app_testing/app_b_py39/main.py

        return fake_db[item_id]
    
    
    @app.post("/items/", response_model=Item)
    async def create_item(item: Item, x_token: str = Header()):
        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
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Dec 17 20:41:43 UTC 2025
    - 1.1K bytes
    - Viewed (0)
  3. docs_src/app_testing/app_b_an_py39/main.py

        return fake_db[item_id]
    
    
    @app.post("/items/", response_model=Item)
    async def create_item(item: Item, x_token: Annotated[str, Header()]):
        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
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Thu Aug 15 22:31:16 UTC 2024
    - 1.1K bytes
    - Viewed (0)
  4. 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[
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Dec 27 12:54:56 UTC 2025
    - 6.8K bytes
    - Viewed (0)
  5. tests/test_tutorial/test_query_params_str_validations/test_tutorial006.py

        response = client.get("/items/", params={"q": "fixedquery"})
        assert response.status_code == 200
        assert response.json() == {
            "items": [{"item_id": "Foo"}, {"item_id": "Bar"}],
            "q": "fixedquery",
        }
    
    
    def test_query_params_str_validations_q_fixedquery_too_short(client: TestClient):
        response = client.get("/items/", params={"q": "fa"})
        assert response.status_code == 422
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Fri Dec 26 10:43:02 UTC 2025
    - 4.4K bytes
    - Viewed (0)
  6. tests/test_tutorial/test_handling_errors/test_tutorial001.py

    def test_get_item():
        response = client.get("/items/foo")
        assert response.status_code == 200, response.text
        assert response.json() == {"item": "The Foo Wrestlers"}
    
    
    def test_get_item_not_found():
        response = client.get("/items/bar")
        assert response.status_code == 404, response.text
        assert response.headers.get("x-error") is None
        assert response.json() == {"detail": "Item not found"}
    
    
    def test_openapi_schema():
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Dec 17 20:41:43 UTC 2025
    - 3.2K bytes
    - Viewed (0)
  7. docs_src/path_params_numeric_validations/tutorial003_py39.py

    from fastapi import FastAPI, Path
    
    app = FastAPI()
    
    
    @app.get("/items/{item_id}")
    async def read_items(*, item_id: int = Path(title="The ID of the item to get"), q: str):
        results = {"item_id": item_id}
        if q:
            results.update({"q": q})
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Dec 17 20:41:43 UTC 2025
    - 268 bytes
    - Viewed (0)
  8. docs_src/path_params_numeric_validations/tutorial004_an_py39.py

    from typing import Annotated
    
    from fastapi import FastAPI, Path
    
    app = FastAPI()
    
    
    @app.get("/items/{item_id}")
    async def read_items(
        item_id: Annotated[int, Path(title="The ID of the item to get", ge=1)], q: str
    ):
        results = {"item_id": item_id}
        if q:
            results.update({"q": q})
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Mar 18 12:29:59 UTC 2023
    - 317 bytes
    - Viewed (0)
  9. docs_src/path_params_numeric_validations/tutorial005_an_py39.py

    from typing import Annotated
    
    from fastapi import FastAPI, Path
    
    app = FastAPI()
    
    
    @app.get("/items/{item_id}")
    async def read_items(
        item_id: Annotated[int, Path(title="The ID of the item to get", gt=0, le=1000)],
        q: str,
    ):
        results = {"item_id": item_id}
        if q:
            results.update({"q": q})
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Mar 18 12:29:59 UTC 2023
    - 331 bytes
    - Viewed (0)
  10. docs_src/path_params_numeric_validations/tutorial001_py39.py

    from typing import Union
    
    from fastapi import FastAPI, Path, Query
    
    app = FastAPI()
    
    
    @app.get("/items/{item_id}")
    async def read_items(
        item_id: int = Path(title="The ID of the item to get"),
        q: Union[str, None] = Query(default=None, alias="item-query"),
    ):
        results = {"item_id": item_id}
        if q:
            results.update({"q": q})
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Dec 17 20:41:43 UTC 2025
    - 364 bytes
    - Viewed (0)
Back to top