python - Flask内如何跳转至其他页面。
巴扎黑
巴扎黑 2017-04-18 10:24:46
0
1
788

为了能从当前的路由跳转至其他路由,我如下写的:

  @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的)
现在很茫然,不知道怎么办 求教

巴扎黑
巴扎黑

Antworte allen(1)
伊谢尔伦

加个点

redirect(url_for(".about"))
Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage
Über uns Haftungsausschluss Sitemap
Chinesische PHP-Website:Online-PHP-Schulung für das Gemeinwohl,Helfen Sie PHP-Lernenden, sich schnell weiterzuentwickeln!