码迷,mamicode.com
首页 > 其他好文 > 详细

flask

时间:2019-01-30 17:13:08      阅读:126      评论:0      收藏:0      [点我收藏+]

标签:ken   错误   pos   企业版   ESS   flask   def   method   小程序   

# -*- coding: utf-8 -*-
# @Time : 2018/12/30 20:55
# @Author : yang dan
# @FileName: mockXCX.py

"""
1.服务名称:挡板程序,模拟企业版微服务 小程序sprint 1st 接口服务
2.接口详情:
1)小程序登录及token刷新:/sns/component/jscode2session | GET
"""

from flask import Flask, request
import json

app = Flask(__name__)


@app.route(‘/‘)
def index():
return ‘flask demo!‘

# 小程序登录及token刷新
@app.route(‘/sns/component/jscode2session‘, methods=[‘GET‘, ‘POST‘])
def card_detail():
if request.method == ‘GET‘:
data = request.form.to_dict()
company_id = data.get(‘Long‘)
if company_id == ‘523144769413582848‘:
resp = """{
"code":0,
"data":{
"errcode":0,
"openid":"obpMo41bszydJKWCvHhyDb1oW9v8",
"session_key":"jTXrZqfLg5bL1ayM3NeusQ=="
},
"msg":"成功"
}
"""
return resp
elif company_id ==‘502565183546195968‘:
resp = """{
"code":0,
"data":{
"errcode":0,
"openid":"ozN_M4i70w2lRAa8IkBhgDmhQTKw",
"session_key":"a2c9D1YQ1WY11Q0ssPRsOQ=="
},
"msg":"成功"
}"""
return resp
else:
return r‘{code:-2, message:"无效或错误的参数!"}‘
else:
return r‘{code:-1, message:"请求方法错误!"}‘

 


if __name__ == ‘__main__‘:
app.run(host=‘0.0.0.0‘, port=80, debug=True)

flask

标签:ken   错误   pos   企业版   ESS   flask   def   method   小程序   

原文地址:https://www.cnblogs.com/perTest/p/10338630.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!