问题很简单
#This works
@app.route("/projects")
def user_home():
return 'projects'
#This works
@app.route("/projects/new", methods=["GET", "POST"])
def create_project():
return 'new project'
#This works
@app.route("/projects/<project_id>")
async def project_detail(project_id):
return 'project detail'
#This works
@app.route("/projects/<project_id>/tasks")
def user_tasks(project_id):
return 'project tasks'
#This gives a 404
@app.route("/projects/<project_id>/tasks/new", methods=["GET", "POST"])
def create_task(project_id):
return 'new project task'
#This works
@app.route("/projects/<project_id>/tasks/<task_id>")
async def task_detail(project_id, task_id):
return 'task detail'
最后一条路线给了我一个 404,即使它遵循与上述相同的逻辑。
这里发生了什么?
如果我能更好地设计我的路线,我愿意接受建议,这是一个简单的主/细节/CRUD 应用程序
(在我实际使用 Quart 时标记 Quart,但现在我认为这并不重要,因为它与烧瓶具有相同的 api)