更新于:
计划对接微信公众号了,配置公众号需要验证服务器
import hashlib
@bp.route("/wechat/", methods=['GET', 'POST'])
def wechat():
_list = ["自定义设置的token", request.args.get('timestamp'), request.args.get("nonce")]
_list.sort()
_str = ''.join(_list)
_encode = hashlib.sha1(_str.encode('utf-8'))
_encode = _encode.hexdigest()
if _encode == request.args.get("signature"):
return request.args.get("echostr")
else:
return ""
pass
转载请注明:【python flask 微信公众号验证】https://jihuo.ma/wechat-mp-auth.html