文章详情页
python - Flask内如何跳转至其他页面。
浏览:140日期: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. javascript - angularjs怎么获取repeat里的某些$index值?2. html5和Flash对抗是什么情况?3. java - spring-security与微信登录的问题?4. html5 - iphone5手机,微信中无法打开优酷链接?5. javascript - 移动端,当出现遮罩层的时候,遮罩层里有div是超出高度scroll的,怎么避免滑动div的时候,body跟随滑动?6. docker-compose 为何找不到配置文件?7. 用Java8的 stream 操作外部集合是否存在并发问题?8. css3 - 请问,如何写这个颜色的(渐变),并且在移动端自适应9. javascript - 求解答:实例对象调用constructor,此时constructor内的this的指向?10. MySQL启动错误
排行榜
