我想在url中传递“top3/1”作为参数。但它返回404错误。你知道吗
这是我的密码:
@APP.route('/get_agent_details_on_voucher_code/<string:code>',methods=['GET'])
def get_agent_details_on_voucher_code(code):
result = []
if code == 'TOP3':
voucher_earning_list = [{'voucher_code':'TOP3/1','agent_id':12345,'voucher_id':8}]
if len(voucher_earning_list)>0:
for item in voucher_earning_list:
get_details = requests.get('http://192.168.1.55:5000/get_agent_details/'+str(item['agent_id']))
get_result = get_details.json()
if len(get_result) > 0:
get_ag_mobileno = get_result[0]['mobile']
result.append({'mobile_no':get_ag_mobileno,'agent_id':item['agent_id'],'voucher_id':item['voucher_id']})
response = jsonify(result)
else:
response = jsonify(result)
else:
response = jsonify(result)
else:
response = jsonify(result)
return response
这是一个棘手的问题:通常使用flask时,必须指定到达最终端点的路径。你知道吗
如果要匹配所有子路由,可以使用类型
path
而不是string
,只需将路由更改为:@APP.route('/get_agent_details_on_voucher_code/<path:code>',methods=['GET'])
这样你就可以得到
/get_agent_details_on_voucher_code/
的所有子路由,记住code
将是一个字符串,你必须提取你需要解析的信息。你知道吗相关问题 更多 >
编程相关推荐