Python Flask 重定向到方法 重定向到网站

from flask import Flask, redirect, url_for

app = Flask(__name__)


# 重定向到百度
@app.route('/index')
def index():
    return redirect("https://www.baidu.com")


# 重定向到自定义函数
@app.route('/index2')
def index2():
    return redirect(url_for('hello'))


@app.route("/")
def hello():
    return "this is hello fun"


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

你可能感兴趣的:(python,flask,开发语言)