news/api/FlowResponse.py

18 lines
479 B
Python
Raw Permalink Normal View History

2022-12-24 12:52:18 +08:00
from fastapi.responses import JSONResponse
def success(msg="操作成功",data=None):
res_json = {}
res_json['code']=200
res_json['msg']=msg
if data!=None:
res_json['data']=data
return JSONResponse(status_code=200, content=res_json)
def error(msg="操作失败",data=None):
res_json = {}
res_json['code']=500
res_json['msg']=msg
if data!=None:
res_json['data']=data
return JSONResponse(status_code=500, content=res_json)