From 3c0fd592e8a7f167cb4601bacd4406617a2a96fd Mon Sep 17 00:00:00 2001 From: eric Date: Fri, 5 May 2023 09:49:01 +0800 Subject: [PATCH] test --- app.py | 44 ++++++++++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 16 deletions(-) diff --git a/app.py b/app.py index 6086d97..8ea6111 100644 --- a/app.py +++ b/app.py @@ -97,6 +97,16 @@ def urlSend(num): sendTg(f"用户输入:{inputArguments},手机号不正确,或者uid参数异常") + +def returnRes(err_code,outputArguments): + # 成功的响应 0成功 -1失败 + content = { + "err_code": err_code, + "data_list": [{"outputArguments": outputArguments}], + } + headers = {"Content-Type": "application/json"} + return JSONResponse(content=content, headers=headers) + @app.get("/") # def read_root(): # return {"Hello": "World"} @@ -147,7 +157,7 @@ async def getphonenum( uid: Union[str, None] = Header(default=None), ): err_code = 0 - outputArguments = "" + outputArguments = "验证码发送成功" print("inputArguments", inputArguments) try: inputArguments = unquote(inputArguments, "utf-8") @@ -172,25 +182,27 @@ async def getphonenum( # 后台发送 background_tasks.add_task(sendFlash, phonenumber, warntext) + # 成功的响应 0成功 -1失败 + content = { + "err_code": err_code, + "data_list": [{"outputArguments": outputArguments}], + } + headers = {"Content-Type": "application/json"} + return JSONResponse(content=content, headers=headers) + else: err_code = -1 + outputArguments = "验证码发送失败,请检查手机号格式,或其他异常" print(f"用户输入:{inputArguments},手机号不正确,或者uid参数异常") # sendTg(f"用户输入:{inputArguments},手机号不正确,或者uid参数异常") - if err_code == 0: - outputArguments = "验证码发送成功" - else: - outputArguments = "验证码发送失败,请检查手机号格式,或其他异常" - # 成功的响应 0成功 -1失败 - content = { - "err_code": err_code, - "data_list": [{"outputArguments": outputArguments}], - } - headers = {"Content-Type": "application/json"} - return JSONResponse(content=content, headers=headers) + # 成功的响应 0成功 -1失败 + content = { + "err_code": err_code, + "data_list": [{"outputArguments": outputArguments}], + } + headers = {"Content-Type": "application/json"} + return JSONResponse(content=content, headers=headers) # # 微信对话平台一定要选择: 随机回复 - # background_tasks.add_task(resData, inputArguments, uid) - # content = {"err_code": 0, "data_list": [{"outputArguments": "test"}]} - # headers = {"Content-Type": "application/json"} - # return JSONResponse(content=content, headers=headers) +s \ No newline at end of file