Reload Flask app when template file changes

前端 未结 10 1685
栀梦
栀梦 2020-11-27 13:04

By default, when running Flask application using the built-in server (Flask.run), it monitors its Python files and automatically reloads the app if its code cha

10条回答
  •  广开言路
    2020-11-27 13:35

    Actually for me TEMPLATES_AUTO_RELOAD = True does not work (0.12 version). I use jinja2 and what i have done:

    1. Create function before_request

      def before_request():
          app.jinja_env.cache = {}
      
    2. Register it in application

      app.before_request(before_request)
      
    3. That's it.

提交回复
热议问题