Coverage for docs_src/handling_errors/tutorial001.py: 100%

8 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2025-12-04 08:29 +0000

1from fastapi import FastAPI, HTTPException 1abcdefg

2 

3app = FastAPI() 1abcdefg

4 

5items = {"foo": "The Foo Wrestlers"} 1abcdefg

6 

7 

8@app.get("/items/{item_id}") 1abcdefg

9async def read_item(item_id: str): 1abcdefg

10 if item_id not in items: 1hijklmnopqrstu

11 raise HTTPException(status_code=404, detail="Item not found") 1ikmoqsu

12 return {"item": items[item_id]} 1hjlnprt