공부

[Python] flask redirect

승가비 2020. 6. 18. 20:43
728x90
import os
from flask import Flask,redirect

app = Flask(__name__)

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

if __name__ == '__main__':
    # Bind to PORT if defined, otherwise default to 5000.
    port = int(os.environ.get('PORT', 5000))
    app.run(host='0.0.0.0', port=port)

https://stackoverflow.com/questions/14343812/redirecting-to-url-in-flask

 

Redirecting to URL in Flask

I'm new to Python and Flask and I'm trying to do the equivalent of Response.redirect as in C# - ie: redirect to a specific URL - how do I go about this? Here is my code: import os from flask import

stackoverflow.com

 

728x90