title: update pyserial data in real time with flask
body: <p>im trying to see data in real time, i have to close the python program to refresh the data. It refreshes only when i close the python file and restart it. i want the data to refresh in real time.</p>
  
  <pre><code>from flask import Flask
  import serial
  
  
  
  app = Flask(__name__)
  
  water = serial.Serial("COM4",9600)
  water1 = water.readline().decode('ascii')
  
  # @ signifies a decorator
  @app.route('/')
  def index():
      return 'This is home page'
  
  @app.route('/plant')
  def plant():
      while True:
          return '&lt;h2&gt;soil is:&lt;/h2&gt; ' + water1 + '%'
  
  
  
  
  
  if __name__=="__main__":
      app.run()
  </code></pre>