我有一个通过 Flask 提供服务的 AngularJS 应用程序。我使用的是 HTML5 路由模式,因此需要将多个 URL 重定向到客户端应用程序。我不确定如何进行通配符匹配才能正确执行此操作。目前我只是匹配多个级别的路径,如下所示:
@app.route('/ui/')
def ui():
return app.send_static_file('index.html')
@app.route('/ui/<path>')
def ui(path):
return app.send_static_file('index.html')
@app.route('/ui/<path>/<path2>')
def ui(path,path2):
return app.send_static_file('index.html')
显然我不喜欢这个,只想有一条路线(一切都从ui/
).
路径网址转换器 http://flask.pocoo.org/docs/api/#url-route-registrations可以为您做到这一点:
@app.route('/ui/<path:p>')
def ui(p):
return app.send_static_file('index.html')
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)