5

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/).

1 Answer 1

7

The path url converter can do this for you:

@app.route('/ui/<path:p>')
def ui(p):
    return app.send_static_file('index.html')
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.