文章详情页
python - Flask内如何跳转至其他页面。
浏览:210日期: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. redis编译报错:cannot find -lgcc_s2. docker - 各位电脑上有多少个容器啊?容器一多,自己都搞混了,咋办呢?3. 如何解决Centos下Docker服务启动无响应,且输入docker命令无响应?4. angular.js - 如何在指令里使用ng-click5. mac里的docker如何命令行开启呢?6. docker - 如何修改运行中容器的配置7. golang - 用IDE看docker源码时的小问题8. docker镜像push报错9. css - 一条线两边有短线的样式表怎么写?10. java中可以通过类的class属性得到该类的字节码文件对象?
排行榜

网公网安备