update
This commit is contained in:
parent
5beb69024d
commit
672743e531
15
test.py
15
test.py
|
@ -1,10 +1,16 @@
|
||||||
import asyncio
|
import asyncio
|
||||||
import json
|
import json
|
||||||
|
|
||||||
|
|
||||||
import uvicorn
|
import uvicorn
|
||||||
from fastapi import FastAPI
|
from fastapi import FastAPI
|
||||||
import paho.mqtt.client as mqtt
|
import paho.mqtt.client as mqtt
|
||||||
|
from pydantic import BaseModel
|
||||||
|
|
||||||
|
|
||||||
|
class BaseResponse(BaseModel):
|
||||||
|
code: int = 200
|
||||||
|
msg: str = None
|
||||||
|
|
||||||
|
|
||||||
app = FastAPI()
|
app = FastAPI()
|
||||||
|
|
||||||
|
@ -64,8 +70,9 @@ async def startup(username, device):
|
||||||
# 取消重来
|
# 取消重来
|
||||||
t.cancel()
|
t.cancel()
|
||||||
await task_start(username, device)
|
await task_start(username, device)
|
||||||
except:
|
return BaseResponse(code=200, msg="success")
|
||||||
pass
|
except Exception as e:
|
||||||
|
return BaseResponse(code=500, msg=e)
|
||||||
|
|
||||||
|
|
||||||
def push_stream(username, device):
|
def push_stream(username, device):
|
||||||
|
@ -91,4 +98,4 @@ def close_stream(username, device):
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
broker = 'mqtt.lihaink.cn'
|
broker = 'mqtt.lihaink.cn'
|
||||||
port = 1883
|
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