This commit is contained in:
eric
2023-05-05 09:49:01 +08:00
parent b05fc4fceb
commit 3c0fd592e8

44
app.py
View File

@@ -97,6 +97,16 @@ def urlSend(num):
sendTg(f"用户输入:{inputArguments},手机号不正确,或者uid参数异常") 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("/") @app.get("/")
# def read_root(): # def read_root():
# return {"Hello": "World"} # return {"Hello": "World"}
@@ -147,7 +157,7 @@ async def getphonenum(
uid: Union[str, None] = Header(default=None), uid: Union[str, None] = Header(default=None),
): ):
err_code = 0 err_code = 0
outputArguments = "" outputArguments = "验证码发送成功"
print("inputArguments", inputArguments) print("inputArguments", inputArguments)
try: try:
inputArguments = unquote(inputArguments, "utf-8") inputArguments = unquote(inputArguments, "utf-8")
@@ -172,25 +182,27 @@ async def getphonenum(
# 后台发送 # 后台发送
background_tasks.add_task(sendFlash, phonenumber, warntext) 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: else:
err_code = -1 err_code = -1
outputArguments = "验证码发送失败,请检查手机号格式,或其他异常"
print(f"用户输入:{inputArguments},手机号不正确,或者uid参数异常") print(f"用户输入:{inputArguments},手机号不正确,或者uid参数异常")
# sendTg(f"用户输入:{inputArguments},手机号不正确,或者uid参数异常") # sendTg(f"用户输入:{inputArguments},手机号不正确,或者uid参数异常")
if err_code == 0: # 成功的响应 0成功 -1失败
outputArguments = "验证码发送成功" content = {
else: "err_code": err_code,
outputArguments = "验证码发送失败,请检查手机号格式,或其他异常" "data_list": [{"outputArguments": outputArguments}],
# 成功的响应 0成功 -1失败 }
content = { headers = {"Content-Type": "application/json"}
"err_code": err_code, return JSONResponse(content=content, headers=headers)
"data_list": [{"outputArguments": outputArguments}],
}
headers = {"Content-Type": "application/json"}
return JSONResponse(content=content, headers=headers)
# # 微信对话平台一定要选择: 随机回复 # # 微信对话平台一定要选择: 随机回复
# background_tasks.add_task(resData, inputArguments, uid) s
# content = {"err_code": 0, "data_list": [{"outputArguments": "test"}]}
# headers = {"Content-Type": "application/json"}
# return JSONResponse(content=content, headers=headers)