INNER CODE UNIT · Python
create_item
hhstore/annotated-py-projects · fastapi/fastapi-0.103.1/docs_src/app_testing/app_b_an/main.py:33
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=400, detail="Item already exists")
fake_db[item.id] = item
return item