| 1 |
from fastapi import FastAPI |
| 2 |
|
| 3 |
app = FastAPI() |
| 4 |
|
| 5 |
|
| 6 |
@app.on_event("shutdown") |
| 7 |
def shutdown_event(): |
| 8 |
with open("log.txt", mode="a") as log: |
| 9 |
log.write("Application shutdown") |
| 10 |
|
| 11 |
|
| 12 |
@app.get("/items/") |
| 13 |
async def read_items(): |
| 14 |
return [{"name": "Foo"}] |