文章详情页
python - Flask内如何跳转至其他页面。
浏览:200日期: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. dockerfile - [docker build image失败- npm install]2. docker gitlab 如何git clone?3. nignx - docker内nginx 80端口被占用4. node.js - mongoDB使用$gte的问题5. 我在centos容器里安装docker,也就是在容器里安装容器,报错了?6. java - mybatis怎么实现在数据库中有就修改,没有就添加7. node.js - nodejs和前端JavaScript 字符串处理结果不一样是什么原因?8. java中关于直接插入排序遇到的问题。9. javascript - c#如何向js传值10. docker安装后出现Cannot connect to the Docker daemon.
排行榜
