Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run Flask without caching templates?

Tags:

python

flask

wsgi

I have a Flask app running with python-socketio and eventlet.

if __name__ == '__main__':
    import eventlet
    import eventlet.wsgi
    eventlet.wsgi.server(eventlet.listen(('', 5000)), app)

Every time I change anything in the templates it does not affect the app and I have to restart the app (CTRL+C and then again python app.py). How can I disable this "cache" or rather enable template reloading?

like image 693
Janusz 'Ivellios' Kamieński Avatar asked Oct 19 '25 01:10

Janusz 'Ivellios' Kamieński


2 Answers

You need to enable the debug mode in your app config: app.debug = True or app.config['DEBUG'] = True. Just make sure you enable this flag only in development since it can have performance and security implications. You can find more details in Flask documentation.

like image 146
Adam Byrtek Avatar answered Oct 22 '25 06:10

Adam Byrtek


In my case app.debug = True did not work, but app.config['TEMPLATES_AUTO_RELOAD'] = True did, per Disable Template Cache Jinja2.

like image 28
David Airapetyan Avatar answered Oct 22 '25 05:10

David Airapetyan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!