This commit is contained in:
xyj 2023-12-18 11:20:29 +08:00
parent 5de0044890
commit fa89f4b648
1 changed files with 6 additions and 4 deletions

10
tool.py
View File

@ -9,12 +9,14 @@ from pydantic import BaseModel
from config import mp4_path, post_record_list_url, post_record_url, info_topic
class BaseResponse(BaseModel):
code: int = pydantic.Field(200, description="MQTT Return Status Code")
msg: str = pydantic.Field("success", description="MQTT Status Message")
# 统一返回
def publish_payload(code, msg):
return json.dumps({
"code": code,
"msg": msg
}, ensure_ascii=False)
return json.dumps(BaseResponse(code=code, msg=msg), ensure_ascii=False)
def exception_handler(func):