对于HTML5 URL模式AngularJS瓶路线 [英] Flask route for AngularJS with HTML5 URL mode

查看:127
本文介绍了对于HTML5 URL模式AngularJS瓶路线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经通过瓶被服务的AngularJS应用。我使用的是HTML5路由模式,因此需要多个URL重定向到客户端应用程序。我不知道该怎么办了通配符匹配需要正确地做到这一点。目前,我只匹配路径的多层次是这样的:

I have an AngularJS app being served via Flask. I am using the HTML5 routing mode and thus need to redirect several URLs to the client app. 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')

很显然,我不喜欢这个,想只是有一条路径(一切开始 UI / )。

推荐答案

路径 URL转换可以为你做到这一点:

The path url converter can do this for you:

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

这篇关于对于HTML5 URL模式AngularJS瓶路线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆