文章詳情頁
python - Flask內(nèi)如何跳轉(zhuǎn)至其他頁面。
瀏覽:175日期:2022-09-03 11:10:20
問題描述
為了能從當前的路由跳轉(zhuǎn)至其他路由,我如下寫的:
@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’)
然后依然沒用,頁面都不會跳轉(zhuǎn) (肯定進了if的)現(xiàn)在很茫然,不知道怎么辦 求教
問題解答
回答1:加個點
redirect(url_for('.about'))
相關(guān)文章:
1. javascript - vscode alt+shift+f 格式化js代碼,通不過eslint的代碼風格檢查怎么辦。。。2. javascript - 如何將一個div始終固定在某個位置;無論屏幕和分辨率怎么變化;div位置始終不變3. html5 - 有可以一次性把所有 css外部樣式轉(zhuǎn)為html標簽內(nèi)style=" "的方法嗎?4. javascript - 有什么比較好的網(wǎng)頁版shell前端組件?5. java - 如何寫一個intellij-idea插件,實現(xiàn)編譯時修改源代碼的目的6. javascript - 原生canvas中如何獲取到觸摸事件的canvas內(nèi)坐標?7. java 中Long 類型如何轉(zhuǎn)換成Double?8. javascript - 求解答:實例對象調(diào)用constructor,此時constructor內(nèi)的this的指向?9. html - vue項目中用到了elementUI問題10. javascript - [js]為什么畫布里不出現(xiàn)圖片呢?在線等
排行榜

熱門標簽