member.py出现报错,请老师帮我看一下
来源:8-3 小程序会员登录和注册3
johnny1981
2019-07-18
报错信息:
requests.exceptions.ProxyError: HTTPSConnectionPool(host=‘api.weixin.qq.com’, port=443): Max retries exceeded with url: /sns/jscode2session?appid=wxd3d31d430fd
b38b9&secret=ff84cb088d7dc5c4c038085c27a76aa3&js_code=001zHPDi10gLHt0c7FEi1iSWDi1zHPDm&grant_type=authorization_code (Caused by ProxyError(‘Cannot connect to p
roxy.’, NewConnectionError(’<urllib3.connection.VerifiedHTTPSConnection object at 0x000001E55400C2B0>: Failed to establish a new connection: [WinError 10061]
由于目标计算机积极拒绝,无法连接。’,)))
Member.py代码
from web.controllers.api import route_api
from flask import request,jsonify
from application import app, db
import requests
@route_api.route( ‘/member/login’, methods = [‘GET’, ‘POST’] )
def login():
resp = { ‘code’: 200, ‘msg’: ‘登录成功’, ‘data’: {} }
req = request.values
code = req[‘code’] if ‘code’ in req else ''
if not code or len( code ) < 1:
resp[‘code’] = -1
resp[‘msg’] = '需要code’
return jsonify( resp )
url = 'https://api.weixin.qq.com/sns/jscode2session?appid={0}&secret={1}&js_code={2}&grant_type=authorization_code'\
.format( app.config['MINA_APP']['appid'], app.config['MINA_APP']['appkey'], code )
r = requests.get( url )
res = r.text
app.logger.info( res )
return jsonify( resp )
1回答
-
johnny1981
提问者
2019-07-18
老师,我解决了,我关闭了“使用代理服务器”就好了
运行结果为:
已经获取openid
00
相似问题
回答 1
回答 7
回答 3
回答 2
回答 5