update
This commit is contained in:
parent
5beb69024d
commit
672743e531
15
test.py
15
test.py
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue