title: Python Flask date update real-time
body: <p>I am building a web app with Python Flask with JavaScript. I am a beginner of Javascript.</p>
  
  <p>The process I do now:</p>
  
  <p>In Flask Python code,<br>
  1. I get data by scrapping the web (numeric data that updates every minute). 
  2. use the data and calculate something and get the final numbers. 
  3. make a list that contains the final numbers
  4. feed the list to a page by adding the list to the page's definition of Flask
  5. Now in HTML get the list by capturing it with {{ data|safe }} tag</p>
  
  <h2>6. use it with Javascript to make a chart.</h2>
  
  <p>The problem is:
  In the step 1, the data I get is being updated every minute. For example, on that web page now there are 15 data points. I parse the last 10 data points from that web page and then I put them in a list in my Python and then do the following steps and make a chart on my webpage. One minute later, in the data source web page, there will be 16 data point available, and I need to get the last 10 data points. In that case, I need to run the python code again to get the latest 10 data points to use them to make a chart on my web page. </p>
  
  <p>So, I need to always run the whole python code which is the whole Flask app init.py file and re-render my webpage to see the updated chart. If I do not re-run the init.py file in my server, then even after 10 minutes or 2 hours, I will only see the data that I parsed for the first time forever.</p>
  
  <p>How should I run the Flask and always get the updated data without always re-run the flask init.py every time.</p>
  
  <p>I thought about using time.sleep(60) so that the flask app python file is run every 1 minutes. But this is really taking alot of time when my code gets much more thinks to calculate. And do not really work.</p>
  
  <p>How should I solve this problem??</p>
  
  <p>Should I use time.sleep ? or is threre better way?</p>