Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 403 for item_id (0.29 sec)

  1. tests/test_extra_routes.py

    
    @app.api_route("/items/{item_id}", methods=["GET"])
    def get_items(item_id: str):
        return {"item_id": item_id}
    
    
    def get_not_decorated(item_id: str):
        return {"item_id": item_id}
    
    
    app.add_api_route("/items-not-decorated/{item_id}", get_not_decorated)
    
    
    @app.delete("/items/{item_id}")
    def delete_item(item_id: str, item: Item):
        return {"item_id": item_id, "item": item}
    
    
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Fri Jul 07 17:12:13 GMT 2023
    - 13.7K bytes
    - Viewed (0)
  2. docs_src/bigger_applications/app_an_py39/routers/items.py

    @router.get("/")
    async def read_items():
        return fake_items_db
    
    
    @router.get("/{item_id}")
    async def read_item(item_id: str):
        if item_id not in fake_items_db:
            raise HTTPException(status_code=404, detail="Item not found")
        return {"name": fake_items_db[item_id]["name"], "item_id": item_id}
    
    
    @router.put(
        "/{item_id}",
        tags=["custom"],
        responses={403: {"description": "Operation forbidden"}},
    )
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Sat Mar 18 12:29:59 GMT 2023
    - 1011 bytes
    - Viewed (0)
  3. tests/test_infer_param_optionality.py

        if user_id is None:
            return [{"item_id": "i1", "user_id": "u1"}, {"item_id": "i2", "user_id": "u2"}]
        else:
            return [{"item_id": "i2", "user_id": user_id}]
    
    
    @item_router.get("/{item_id}")
    def get_item(item_id: str, user_id: Optional[str] = None):
        if user_id is None:
            return {"item_id": item_id}
        else:
            return {"item_id": item_id, "user_id": user_id}
    
    
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Fri Jul 07 17:12:13 GMT 2023
    - 13.3K bytes
    - Viewed (0)
  4. docs_src/body_updates/tutorial002_py310.py

    }
    
    
    @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]
        stored_item_model = Item(**stored_item_data)
        update_data = item.dict(exclude_unset=True)
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Fri Jan 07 14:11:31 GMT 2022
    - 1010 bytes
    - Viewed (0)
  5. docs_src/dependencies/tutorial008c.py

        except InternalError:
            print("Oops, we didn't raise again, Britney 😱")
    
    
    @app.get("/items/{item_id}")
    def get_item(item_id: str, username: str = Depends(get_username)):
        if item_id == "portal-gun":
            raise InternalError(
                f"The portal gun is too dangerous to be owned by {username}"
            )
        if item_id != "plumbus":
            raise HTTPException(
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Sat Feb 24 23:06:37 GMT 2024
    - 660 bytes
    - Viewed (0)
  6. docs_src/bigger_applications/app_an/routers/items.py

    @router.get("/")
    async def read_items():
        return fake_items_db
    
    
    @router.get("/{item_id}")
    async def read_item(item_id: str):
        if item_id not in fake_items_db:
            raise HTTPException(status_code=404, detail="Item not found")
        return {"name": fake_items_db[item_id]["name"], "item_id": item_id}
    
    
    @router.put(
        "/{item_id}",
        tags=["custom"],
        responses={403: {"description": "Operation forbidden"}},
    )
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Sat Mar 18 12:29:59 GMT 2023
    - 1011 bytes
    - Viewed (0)
  7. docs_src/additional_status_codes/tutorial001_an_py39.py

    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[Union[str, None], Body()] = None,
        size: Annotated[Union[int, None], Body()] = None,
    ):
        if item_id in items:
            item = items[item_id]
            item["name"] = name
            item["size"] = size
            return item
        else:
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Sat Mar 18 12:29:59 GMT 2023
    - 705 bytes
    - Viewed (0)
  8. docs_src/path_params/tutorial001.py

    from fastapi import FastAPI
    
    app = FastAPI()
    
    
    @app.get("/items/{item_id}")
    async def read_item(item_id):
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Thu Mar 26 19:09:53 GMT 2020
    - 138 bytes
    - Viewed (0)
  9. tests/test_path.py

                        "loc": ["path", "item_id"],
                        "msg": "Input should be a valid integer, unable to parse string as an integer",
                        "input": "foobar",
                    }
                ]
            }
        ) | IsDict(
            # TODO: remove when deprecating Pydantic v1
            {
                "detail": [
                    {
                        "loc": ["path", "item_id"],
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Thu Apr 18 19:40:57 GMT 2024
    - 34.4K bytes
    - Viewed (0)
  10. docs_src/using_request_directly/tutorial001.py

    from fastapi import FastAPI, Request
    
    app = FastAPI()
    
    
    @app.get("/items/{item_id}")
    def read_root(item_id: str, request: Request):
        client_host = request.client.host
    Python
    - Registered: Sun Apr 21 07:19:11 GMT 2024
    - Last Modified: Thu Mar 26 19:09:53 GMT 2020
    - 230 bytes
    - Viewed (0)
Back to top