Hot reload Flask app?

sjeik_appie at hotmail.com sjeik_appie at hotmail.com
Thu Oct 1 16:52:22 EDT 2020


   On 1 Oct 2020 17:58, Roland Müller via Python-list
   <python-list at python.org> wrote:

     On 2020-10-01 16:33, sjeik_appie at hotmail.com wrote:
     >     Hi,
     >     I would like to create a "/reload" view in my Flask app, so I
     could easily
     >     and safely reload it when code, templates etc change. Similar to
     what
     >     happens when running the app with the debug server. I am using
     Nginx and
     >     Gevent on a recent Ubuntu system with Python 3.6.
     >     My strategy would be to gracefully stop Gevent [1], then do
     >     os.kill(os.getpid(), signal.SIGHUP). I have not yet tried this
     (not
     >     working today!). Just wondering if there are best practices.
     >     Thanks!
     >     Albert-Jan
     >     [1]
     >    
     http://www.gevent.org/api/gevent.baseserver.html#gevent.baseserver.BaseServer.stop

     Running flask app.run(debug=True) will make the Flask server watching
     the filesystem for source code changes and re-deploy your app.

     https://pythonhosted.org/Flask-Debug/ 

   ==》 Hi,
   Thanks. I was aware of running it in debug mode, but I was looking for
   domething to use in production. I checked how werkzeug does it, see line
   160: https://github.com/pallets/werkzeug/blob/master/src/werkzeug/_reloader.py
   I'll study this in more detail tomorrow.
   Best wishes,
   Albert-Jan


More information about the Python-list mailing list