python - Catch all routes for Flask -


this question has answer here:

i'm using flask react. i'd create catch route similar (although doesn't work):

@app.route('*') def get():     return render_template('index.html') 

since app use react , it's using index.html mount react components, i'd every route request point index.html page in templates. there way (or using redirect best way)?

you can follow guideline: http://flask.pocoo.org/snippets/57/

from flask import flask app = flask(__name__)  @app.route('/', defaults={'path': ''}) @app.route('/<path:path>') def catch_all(path):     return 'you want path: %s' % path  if __name__ == '__main__':     app.run() 

Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -