Files
fastapi/docs_src/events/tutorial002_py39.py
2025-12-17 21:41:43 +01:00

15 lines
255 B
Python

from fastapi import FastAPI
app = FastAPI()
@app.on_event("shutdown")
def shutdown_event():
with open("log.txt", mode="a") as log:
log.write("Application shutdown")
@app.get("/items/")
async def read_items():
return [{"name": "Foo"}]