Coverage for docs_src/events/tutorial002.py: 100%

9 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2025-05-05 00:03 +0000

1from fastapi import FastAPI 1abcdef

2 

3app = FastAPI() 1abcdef

4 

5 

6@app.on_event("shutdown") 1abcdef

7def shutdown_event(): 1abcdef

8 with open("log.txt", mode="a") as log: 1gmhniojpkqlr

9 log.write("Application shutdown") 1gmhniojpkqlr

10 

11 

12@app.get("/items/") 1abcdef

13async def read_items(): 1abcdef

14 return [{"name": "Foo"}] 1ghijkl