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')
Obviously I don't like this and would like to just have one route (everything starting with 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')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With