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)
11-12
4万+
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
09-21
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交