Token for AngularJS with HTML5 URL Mode

I have an AngularJS application through Flask. I am using HTML5 routing mode and therefore it is necessary to redirect multiple URLs to the client application. I am not sure how to make a wildcard requiring it to be done correctly. Currently, I am simply mapping several levels of the path as follows:

@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 I just need one route (everything starting with ui/ ).

+4
source share
1 answer

The url converter path can do this for you:

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

Source: https://habr.com/ru/post/1480666/


All Articles