render_template和重定向之间的区别? [英] Difference between render_template and redirect?

查看:402
本文介绍了render_template和重定向之间的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

return redirect(url_for('index', var=var))
return render_template('index.html', var=var)

这两行本质上是同一回事吗?

Are these two lines essentially the same thing?

这两个功能有什么区别?

What is the difference between the two functions?

推荐答案

redirect向浏览器返回302标头,其标头Location作为index函数的URL. render_template返回200,并将index.html模板作为该URL的内容返回.

redirect returns a 302 header to the browser, with its Location header as the URL for the index function. render_template returns a 200, with the index.html template returned as the content at that URL.

这篇关于render_template和重定向之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆