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
Post a Comment