title: Is it possible to dynamically update a rendered template in Flask, server-side?
body: <p>I currently have a Flask web server that pulls data from a JSON API using the built-in requests object.</p>
  
  <p>For example:</p>
  
  <pre><code>def get_data():
      response = requests.get("http://myhost/jsonapi")
      ...
      return response
  
  @main.route("/", methods=["GET"])
  def index():
      return render_template("index.html", response=response)
  </code></pre>
  
  <p>The issue here is that naturally the GET method is only run once, the first time get_data is called. In order to refresh the data, I have to stop and restart the Flask wsgi server. I've tried wrapping various parts of the code in a while True / sleep loop but this prevents werkzeug from loading the page.</p>
  
  <p>What is the most Pythonic way to dynamically GET the data I want without having to reload the page or restart the server?</p>