24 lines
437 B
Python
24 lines
437 B
Python
from contextlib import asynccontextmanager
|
|
|
|
from fastapi import FastAPI
|
|
|
|
from poo import PooRecorder
|
|
|
|
recorder = PooRecorder()
|
|
|
|
|
|
@asynccontextmanager
|
|
async def _lifespan(_app: FastAPI): # noqa: ANN202
|
|
await recorder.start()
|
|
yield
|
|
await recorder.stop()
|
|
|
|
|
|
app = FastAPI(lifespan=_lifespan)
|
|
|
|
|
|
@app.put("/record/s={status}")
|
|
async def record(status: str) -> dict:
|
|
await recorder.record(status)
|
|
return {"status": status}
|