16
我正在使用Flask 0.9。烧瓶URL路由:路由几个URL到相同的功能
现在我想航线三个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):
会不会有更好的解决办法?
非常简单,直观,有效的解决方案。 – tmthyjames