Flask可选url参数不工作

2024-05-11 21:01:45 发布

您现在位置:Python中文网/ 问答频道 /正文

@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或{} 如果我启动一个调试器,我可以看到work_id = None。在

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

为什么会这样?我在路由规则上有什么问题吗?在


Tags: noneidmodlocalhosthttpgetdefpost