티스토리 뷰

공부

[Python] flask redirect

seunggabi 승가비 2020. 6. 18. 20:43
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

 

'공부' 카테고리의 다른 글

[Hive] SHOW TABLES FROM `db`  (0) 2020.06.18
[Java] lombok @ToString (CSV, Fields)  (0) 2020.06.18
[Python] flask redirect  (0) 2020.06.18
[Python] timedelta  (0) 2020.06.18
[Python] Running setup.py install for mysqlclient ... error  (0) 2020.06.18
[MySQL] default value  (0) 2020.06.13
댓글
댓글쓰기 폼