This commit is contained in:
quantulr
2024-01-26 11:31:36 +08:00
parent 6b67995704
commit 077076f234
50 changed files with 140 additions and 141 deletions

View File

@ -10,18 +10,11 @@ app = FastAPI()
async def add_stream(data: dict):
redis = await aioredis.from_url("redis://localhost", db=0)
await redis.lpush("event", json.dumps(data))
# await redis.xadd("hik-event", {"event": json.dumps(data)})
redis = await aioredis.Redis(host="127.0.0.1", port=6379)
await redis.lpush("hik-sub-event", json.dumps(data))
await redis.close()
@app.post("/upload")
async def upload_file(file: UploadFile):
print(file)
return {"message": "success"}
@app.get("/")
async def root():
return {"message": "Hello World"}
@ -30,7 +23,7 @@ async def root():
@app.post("/eventRcv")
async def event_rcv(data: dict, background_tasks: BackgroundTasks):
background_tasks.add_task(add_stream, data)
return {"data": data}
return {"msg": "success"}
def run_app():