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

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -