flask redirect to url

from flask import Flask, redirect

app = Flask(__name__)

@app.route('/')
def index():
    return redirect("http://www.example.com", code=302)

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

Here is what the above code is Doing:
1. We’re creating a Flask instance.
2. We’re creating a route that redirects to a different URL.
3. We’re running the app.