接口 接收post请求和get请求
需求:接收post和get请求的数据
def get_data():
# 默认返回内容
return_dict = {'return_code': '200', 'return_info': '处理成功', 'result': False}
# 判断传入的json数据是否为空
if request.get_data() is None:
return_dict['return_code'] = '5004'
return_dict['return_info'] = '请求参数为空'
return json.dumps(return_dict, ensure_ascii=False)
get_data = request.args.to_dict()
group_id = get_data.get('groupId')
date = get_data.get('date')
return_dict['result'] = 1
return_dict['group_id'] = group_id
return_dict['date'] = date
def post_data(): # 判断传入的json数据是否为空 if request.get_data() is None: recognize_info = {} recognize_info['return_code'] = '5004' recognize_info['return_info'] = '请求参数为空' return jsonify(recognize_info) group_id = request.form.get('groupId') #获取数据 date = request.form.get('date') # 对参数进行操作(order_dis为功能函数)
recognize_info = order_dis(group_id,date) # print(recognize_info)
return jsonify(recognize_info)