title: Flask program remains in the loop
body: <p>I wrote a small &quot;tool&quot; for my Keylight 34792A, it should take a measurement and output it to me as a variable. It gives me the result in the console, but the page remains loading. In addition, the device remains in an &quot;ADRS&quot; loop.</p>
  <p>Do you see what might indicate an error? I'm a little overwhelmed.</p>
  <p>The output reads:</p>
  <pre><code>Verbunden mit: Agilent Technologies,34972A,MY49020558,1.16-1.12-02-02
  
  2021,12,19,15,50,19.667
  
  +25.280° 101
  +95.400° 102
  +20.540° 103
  +34.190° 104
  +42.570° 105
  </code></pre>
  <p>The Code is:</p>
  <pre><code>from flask import Flask
  import pyvisa
  from time import sleep
  from datetime import datetime
  
  app = Flask(__name__)
  
  ergebnis = None
  
  @app.route('/', methods = ['POST', 'GET'])
  
  def messung():
  
      rm = pyvisa.ResourceManager('@py')
      dmm = rm.open_resource('TCPIP0::192.168.178.101::inst0::INSTR')
      print(&quot;Verbunden mit: &quot; + dmm.query('*IDN?'))
  
      time = datetime.now().strftime(&quot;%H,%M,%S&quot;)
      date = datetime.now().strftime(&quot;%Y,%m,%d&quot;)
  
  
      dmm.write(&quot;SYST:TIME &quot; + time)
      dmm.write(&quot;SYST:DATE &quot; + date)
  
      dmm.timeout = 5000
      dmm.write(&quot;*CLS&quot;)
      dmm.write(&quot;*RST&quot;)
  
      scanIntervals = 0
      numberScans = 1
      channelDelay = 0.1
      scanlist = &quot;(@101:105)&quot;
  
      dmm.write(&quot;CONF:TEMP TC,T,(@101:105)&quot;)
  
      dmm.write(&quot;ROUTE:SCAN &quot; + scanlist)
      dmm.write(&quot;ROUTE:SCAN:SIZE?&quot;)
      numberChannels = int(dmm.read())
      dmm.write(&quot;FORMAT:READING:CHAN ON&quot;)
      dmm.write(&quot;FORMAT:READING:TIME ON&quot;)
      dmm.write(&quot;ROUT:CHAN:DELAY &quot; + str(channelDelay)+&quot;,&quot;+scanlist)
      dmm.write(&quot;TRIG:COUNT &quot; + str(numberScans))
      dmm.write(&quot;TRIG:SOUR TIMER&quot;)
      dmm.write(&quot;TRIG:TIMER &quot; + str(scanIntervals))
      dmm.write(&quot;INIT;:SYSTEM:TIME:SCAN?&quot;)
      #ausgabe vom Zeitpunkt der Messung
      print(dmm.read())
  
      sleep(3)
      points = 0
      while (points == 0):
          dmm.write(&quot;DATA:POINTS?&quot;)
          points = int(dmm.read())
  
      #jedes ergebnis hat eine Zeile
      for chan in range(1, 100):
          dmm.write(&quot;DATA:REMOVE? 1&quot;)
          raw = str(dmm.read())      #ergebnise
          print(raw[0:2] + raw[4] + &quot;.&quot; + raw[5:8] + &quot;°&quot; + &quot; &quot; + raw[-4:-1])
          points = 0
  
          #auf daten warten
          while (points == 0):
              dmm.write(&quot;DATA:POINTS?&quot;)
              points = int(dmm.read())
      dmm.close()
      return str(ergebnis)
  
  
  
  if __name__ == '__main__':
  
      app.run()
  </code></pre>