我正在使用 Flask 0.9。
现在我想将三个 url 路由到同一个函数:
/item/<int:appitemid>
/item/<int:appitemid>/
/item/<int:appitemid>/<anything can be here>
该<anything can be here>
部分永远不会在函数中使用。
我必须复制相同的函数两次才能实现这个目标:
@app.route('/item/<int:appitemid>/')
def show_item(appitemid):
@app.route('/item/<int:appitemid>/<path:anythingcanbehere>')
def show_item(appitemid, anythingcanbehere):
会有更好的解决方案吗?