This commit is contained in:
xyj 2024-01-03 14:01:50 +08:00
parent 5beb69024d
commit 672743e531
1 changed files with 11 additions and 4 deletions

15
test.py
View File

@ -1,10 +1,16 @@
import asyncio
import json
import uvicorn
from fastapi import FastAPI
import paho.mqtt.client as mqtt
from pydantic import BaseModel
class BaseResponse(BaseModel):
code: int = 200
msg: str = None
app = FastAPI()
@ -64,8 +70,9 @@ async def startup(username, device):
# 取消重来
t.cancel()
await task_start(username, device)
except:
pass
return BaseResponse(code=200, msg="success")
except Exception as e:
return BaseResponse(code=500, msg=e)
def push_stream(username, device):
@ -91,4 +98,4 @@ def close_stream(username, device):
if __name__ == '__main__':
broker = 'mqtt.lihaink.cn'
port = 1883
uvicorn.run(app, host="0.0.0.0", port=8001)
uvicorn.run(app, host="127.0.0.1", port=8001)