我有一个通过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')
Run Code Online (Sandbox Code Playgroud)
显然我不喜欢这个,并希望只有一条路线(一切都以ui/)开头.
路径网址转换器可以为您执行此操作:
@app.route('/ui/<path:p>')
def ui(p):
return app.send_static_file('index.html')
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2016 次 |
| 最近记录: |