0

I'm building a webapp using gunicorn, flask, and plotly's dash. I'm using guncorns's --reload option which automatically reloads or resets the workers if any code is modified. I have observed this basically restarts my entire web app. At the start of my webapp I'm initializing a client connection and cursor to documents inside a mongo db. Then the webapp starts graphing stuff. If I modified the HTML of the webapp, I want gunicorn to reload the HTML side of things only, and not reinitialize the mongo db each time. Is there any way I can avoid reloading everything using gunicorn's reload? Or maybe some other alternative?

Martijn Pieters
  • 963,270
  • 265
  • 3,804
  • 3,187
jersey bean
  • 2,696
  • 1
  • 25
  • 35

1 Answers1

0

Gunicorn only reloads the Python code. It will not reload your HTML code.

Your HTML code should be read each time a request is made, unless it is using cached version. Try disabling cache on the page which you are trying to re-load.

These links should point you towards a solution:

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

https://gist.github.com/arusahni/9434953

Disable cache on a specific page using Flask

Sazzy
  • 1,764
  • 3
  • 19
  • 24
  • Thanks for the comment. My first attempt to disable cache didn't help. Although I feel like i need to study this a bit closer to fully understand how it works, since its a bit confusing to understand how Plotly's Dash works alongside with Flask. – jersey bean Apr 23 '18 at 17:44