@mod.route('/participate/<survey_id>/', defaults = {'work_id':None}, methods = ['GET','POST'])
@mod.route('/pariicipate/<survey_id>/<work_id>', methods = ['GET', 'POST'])
def participate(survey_id, work_id):
/* do_something .. */
我可以访问http://localhost:5000/participate/512dc365fe8974149091be1f
或http://localhost:5000/participate/512dc365fe8974149091be1f/
如果我启动调试器,我可以看到work_id = None
。
如果我尝试http://localhost:5000/participate/512dc365fe8974149091be1f/512dc365fe8974149091be1f
或http://localhost:5000/participate/512dc365fe8974149091be1f/512dc365fe8974149091be1f/
,我会得到404。
为什么会这样?我有没有做过路由规则的错误?
答案 0 :(得分:2)
你的第二条路线中有拼写错误:)
@mod.route('/pariicipate/<survey_id>/<work_id>', methods = ['GET', 'POST'])
应该是
@mod.route('/participate/<survey_id>/<work_id>', methods = ['GET', 'POST'])