文章詳情頁
python - Flask內如何跳轉至其他頁面。
瀏覽:163日期: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'))
相關文章:
1. Docker for Mac 創建的dnsmasq容器連不上/不工作的問題2. docker - 如何修改運行中容器的配置3. docker安裝后出現Cannot connect to the Docker daemon.4. nignx - docker內nginx 80端口被占用5. python3.x - python連oanda的模擬交易api獲取json問題第五問6. javascript - QWebEngineView 如何爬 angular 的動態數據?7. css3 - 沒明白盒子的height隨width的變化這段css是怎樣實現的?8. javascript - webpack熱加載配置不生效9. java - SSH框架中寫分頁時service層中不能注入分頁類10. java - instance method中 static后的<K>是什么意思?
排行榜
