Coverage for docs_src/handling_errors/tutorial001.py: 100%
8 statements
« prev ^ index » next coverage.py v7.6.1, created at 2024-08-08 03:53 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2024-08-08 03:53 +0000
1from fastapi import FastAPI, HTTPException 1abcde
3app = FastAPI() 1abcde
5items = {"foo": "The Foo Wrestlers"} 1abcde
8@app.get("/items/{item_id}") 1abcde
9async def read_item(item_id: str): 1abcde
10 if item_id not in items: 1abcde
11 raise HTTPException(status_code=404, detail="Item not found") 1abcde
12 return {"item": items[item_id]} 1abcde