Sometimes, we want to reload Python Flask app when template file changes.
In this article, we’ll look at how to reload Python Flask app when template file changes.
How to reload Python Flask app when template file changes?
To reload Python Flask app when template file changes, we set the TEMPLATES_AUTO_RELOAD
to True
.
For instance, we write
from flask import Flask, render_template, request, url_for, redirect
app = Flask(__name__)
app.config["TEMPLATES_AUTO_RELOAD"] = True
to config our Flask app
to auto reload the app when we changed the template code.
Conclusion
To reload Python Flask app when template file changes, we set the TEMPLATES_AUTO_RELOAD
to True
.