文章詳情頁
python - Flask內如何跳轉至其他頁面。
瀏覽:254日期: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的)現(xiàn)在很茫然,不知道怎么辦 求教
問題解答
回答1:加個點
redirect(url_for('.about'))
相關文章:
1. javascript - immutable配合react提升性能?2. javascript - sublime快鍵鍵問題3. Apache 已經把網站根目錄的改為allow from all了,但是服務器還是不能訪問?4. vue.js - Vue 如何像Angular.js watch 一樣監(jiān)聽數(shù)據(jù)變化5. css - 寫頁面遇到個布局問題,求大佬們幫解答,在線等,急!~6. javascript - nodejs關于進程間發(fā)送句柄的一點疑問7. 配置Apache時,添加對PHP的支持時語法錯誤8. 實現(xiàn)bing搜索工具urlAPI提交9. phpstudy8.1支持win11系統(tǒng)嗎?10. javascript - 移動端上不能實現(xiàn)拖拽布局嗎?
排行榜

熱門標簽
網公網安備