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

老师,我解决了,我关闭了“使用代理服务器”就好了//img.mukewang.com/szimg/5d2fe09609b4511508000632.jpg


运行结果为:

//img.mukewang.com/szimg/5d2fe0c709b4395213660736.jpg

已经获取openid

0
0

Python Flask构建微信小程序订餐系统(可用于毕设)

微信小程序 + Python Flask 打造订餐系统全栈应用,可用于毕设。

1709 学习 · 1889 问题

查看课程