简体   繁体   English

使用HTML5 URL模式的AngularJS的Flask路线

[英]Flask route for AngularJS with HTML5 URL mode

I have an AngularJS app being served via Flask. 我有一个通过Flask提供的AngularJS应用程序。 I am using the HTML5 routing mode and thus need to redirect several URLs to the client app. 我正在使用HTML5路由模式,因此需要将多个URL重定向到客户端应用程序。 I'm not sure how to do the wildcard matching needing to do this correctly. 我不确定如何正确地进行通配符匹配。 Currently I just match multiple levels of path like this: 目前我只匹配多个级别的路径,如下所示:

@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')

Obviously I don't like this and would like to just have one route (everything starting with ui/ ). 显然我不喜欢这个,并希望只有一条路线(一切都以ui/开头)。

The path url converter can do this for you: 路径网址转换器可以为您执行此操作:

@app.route('/ui/<path:p>')
def ui(p):
    return app.send_static_file('index.html')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM