您的位置:首頁技術文章
文章詳情頁

python - Flask內如何跳轉至其他頁面。

瀏覽:132日期:2022-09-03 11:10:20

問題描述

為了能從當前的路由跳轉至其他路由,我如下寫的:

@app.route(’/’,methods=[’POST’,’GET’])def index(): if request.args.get(’data’,type=int)==1: #判斷是否前往return redirect(url_for(’about’)) return render_template(’index.html’)@app.route(’/about’) def about(): : :return render_template(’about.html’)

但是沒有用,然后我又改成:

return render_template(’about.html’)

然后依然沒用,頁面都不會跳轉 (肯定進了if的)現在很茫然,不知道怎么辦 求教

問題解答

回答1:

加個點

redirect(url_for('.about'))

標簽: Python 編程
相關文章:
国产综合久久一区二区三区