title: Flask Countdown Timer without Sleep
body: <p>I'm writing a web app with Flask and when I try to create a countdown timer that can be started by high level user (allowing for a response by low level users in that time frame) and use time.sleep(1) in the countdown function, it freezes the web app for all users until the countdown is done.</p>
  
  <p>How do I countdown in Flask without having the app freeze during the countdown? Is this a threading issue or do I need a different strategy?</p>
  
  <pre><code>@main.route('/class/&lt;class_name&gt;', methods = ['GET', 'POST'])
  @login_required
  def view_class(class_name):
      if class_name is None:
          abort(404)
      form = AttendanceForm()
      check_in_permitted = False
      c = Class.query.filter_by(id = class_name).first()
      if current_user.is_instructor():
          if form.validate_on_submit():
              t = int(form.seconds.data)
              check_in_permitted = True
              while t &gt;= 0:
                  print(t)
                  time.sleep(1)
                  t -= 1
              print("TIME")
              check_in_permitted = False
  
      elif current_user.is_user():
          if check_in_permitted == True:
              form = CheckInForm()
  
      return render_template('view_class.html', c = c, form = form)
  </code></pre>