@app.route('/test',methods=['GET','POST'])
def _test():
try:
load = request.data.decode("utf-8")
msg = json.loads(load)
logger.warning(f"json: {msg}")
ret = f"""
<xml>
<ToUserName><![CDATA[{msg["FromUserName"]}]]></ToUserName>
<FromUserName><![CDATA[{msg["ToUserName"]}]]></FromUserName>
<CreateTime>{int(time.time())}</CreateTime>
<MsgType><![CDATA[text]]></MsgType>
<Content><![CDATA[你好]]></Content>
</xml>
"""
print(ret)
logger.warning("正常返回了!")
return ret
except Exception as e:
print(e)
logger.warning("错误了")
logger.error(traceback.format_exc())
abort(501)