512dc365fe8974149091be1f

512dc365fe8974149091be1f

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center




7年前关闭。





@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/512dc365fe8974149091be1fhttp://localhost:5000/participate/512dc365fe8974149091be1f/
如果启动调试器,则可以看到work_id = None

如果我尝试http://localhost:5000/participate/512dc365fe8974149091be1f/512dc365fe8974149091be1fhttp://localhost:5000/participate/512dc365fe8974149091be1f/512dc365fe8974149091be1f/我得到404。

为什么会这样呢?我在路由规则上做错了什么吗?

最佳答案

您的第二条路线中有错字:)

@mod.route('/pariicipate/<survey_id>/<work_id>', methods = ['GET', 'POST'])


应该

@mod.route('/participate/<survey_id>/<work_id>', methods = ['GET', 'POST'])

10-08 03:57