diff --git a/lib/service/local.py b/lib/service/local.py index 03cbd25..00b01ea 100644 --- a/lib/service/local.py +++ b/lib/service/local.py @@ -7,4 +7,4 @@ def check_local(txt): risk = 0 if len(result) > 0: risk = 1 - return {'errcode': 0, 'risk': risk, 'reason': result} \ No newline at end of file + return {'errcode': 0, 'risk': risk, 'reason': result} diff --git a/main.py b/main.py index 1b0a49e..9ab6988 100644 --- a/main.py +++ b/main.py @@ -15,13 +15,44 @@ class Item(BaseModel): content: str -@app.post("/check") -async def check_content(item: Item): - # res_wechat = await msg_sec_check(item.content) - # res_baidu = await check_baidu(item.content) +@app.post("/check_wx") +async def check_wx(item: Item): + res_wechat = await msg_sec_check(item.content) + return res_wechat + + +@app.post("/check_bd") +async def check_wx(item: Item): + res_baidu = await check_baidu(item.content) + return res_baidu + + +@app.post("/check_local") +async def check_local_def(item: Item): res_local = check_local(item.content) return res_local +@app.post("/check_all") +async def check_content(item: Item): + res_wechat = await msg_sec_check(item.content) + result = {'errcode': 1} + if res_wechat['errcode'] == 0: + result['errcode'] = 0 + result['wx'] = res_wechat['risk'] + result['reason_wx'] = res_wechat['reason'] + res_baidu = await check_baidu(item.content) + if res_baidu['errcode'] == 0: + result['errcode'] = 0 + result['bd'] = res_baidu['risk'] + result['reason_bd'] = res_baidu['reason'] + res_local = check_local(item.content) + if res_local['errcode'] == 0: + result['errcode'] = 0 + result['local'] = res_local['risk'] + result['reason_local'] = res_local['reason'] + return result + + if __name__ == "__main__": uvicorn.run(app, host="0.0.0.0", port=8009)