From 34077921e8d7f125d1bab7312fdfb4533a4b0d08 Mon Sep 17 00:00:00 2001 From: zhl Date: Thu, 17 Jun 2021 12:46:48 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E6=80=BB=E7=9A=84=E5=AE=A1?= =?UTF-8?q?=E6=A0=B8=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/service/local.py | 2 +- main.py | 39 +++++++++++++++++++++++++++++++++++---- 2 files changed, 36 insertions(+), 5 deletions(-) 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)