update
This commit is contained in:
@ -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():
|
||||
|
Reference in New Issue
Block a user