Files
home-automation-backend/src/main.py

24 lines
450 B
Python
Raw Normal View History

2024-07-16 15:55:45 +02:00
from contextlib import asynccontextmanager
from fastapi import FastAPI
from src.recorder.poo import PooRecorder
2024-07-16 15:55:45 +02:00
recorder = PooRecorder()
@asynccontextmanager
2024-07-17 16:44:30 +02:00
async def _lifespan(_app: FastAPI): # noqa: ANN202
2024-07-16 15:55:45 +02:00
await recorder.start()
yield
await recorder.stop()
app = FastAPI(lifespan=_lifespan)
@app.put("/record/s={status}")
async def record(status: str) -> dict:
2024-07-17 16:44:30 +02:00
await recorder.record(status)
2024-07-16 15:55:45 +02:00
return {"status": status}