【问题标题】:Flask route for AngularJS with HTML5 URL mode带有 HTML5 URL 模式的 AngularJS 的烧瓶路由
【发布时间】:2013-05-14 09:04:21
【问题描述】:

我有一个通过 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/ 开头)。

【问题讨论】:

    标签: angularjs flask


    【解决方案1】:

    路径url converter 可以为你做到这一点:

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

    【讨论】:

      猜你喜欢
      • 2017-11-22
      • 2016-04-20
      • 1970-01-01
      • 1970-01-01
      • 2021-03-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-10-21
      相关资源
      最近更新 更多