Difference between render_template and redirect?

One URL endpoint can have many different render_template statements and thus render different page templates from your templates folder. On the other hand, using a redirect changes the URL itself and thus calls the methods associated to that route.


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.


On a much simpler note, consider this - If none of your endpoints rendered templates, and all your redirects were to url's of endpoints within your app, there would be nothing to render!

It's like pointing the way to a place that won't show itself.

Tags:

Python

Flask