Catch all routes for Flask [duplicate]

You can follow this guideline: https://flask.palletsprojects.com/en/1.1.x/api/#url-route-registrations

from flask import Flask
app = Flask(__name__)

@app.route("https://stackoverflow.com/", defaults={'path': ''})
@app.route('/<path:path>')
def catch_all(path):
    return 'You want path: %s' % path

if __name__ == '__main__':
    app.run()

Leave a Comment