文章详情页
python - Flask内如何跳转至其他页面。
浏览:171日期: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. css - 关于伪类背景问题2. html - 移动端radio无法选中3. apache - 怎么给localhost后面默认加上8080端口4. html5 - 如何实现图中的刻度渐变效果?5. python - 用scrapy-splash爬取网站 为啥iframe下的内容没有被返回6. mysql - 数据库建字段,默认值空和empty string有什么区别 1107. python - django的模板预加载8. 关于Navicat连接到mysql,我改了root的密码后,Navicat连接报错1862?9. mysql起不来了,为什么?10. mysql里show full processlist,进程很少
排行榜
