文章详情页
python - Flask内如何跳转至其他页面。
问题描述
为了能从当前的路由跳转至其他路由,我如下写的:
@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. mysql - 数据库建字段,默认值空和empty string有什么区别 1102. 问一下代码哪里出错了????3. mybatis - Java关于Mysql的随机id生成4. Mac下phpinfo和php -m里的扩展不一致怎么解决?5. 求问:其它输出都正常,就是错误输出是乱码!6. python - UTC格式转换成本地时间7. angular.js - 在ionic下,利用javascript导入百度地图,pc端可以显示,移动端无法显示8. python - 如何使用requests模块在一个post中提交含有多个相同名称的数据?9. windows - Mysql数据库部署 能否不安装服务?10. 冒昧问一下,我这php代码哪里出错了???
排行榜