code: def wait_for_server(host, port, cancel_event=None):
      
      while not is_server_running(host, port):
          # Stop waiting if shutting down
          if cancel_event and cancel_event.is_set():
              return False
          time.sleep(0.1)
      return True
docs: Blocks until a local server is listening on the specified
      host and port. Set cancel_event to cancel the wait.
  
      This is intended to be used in conjunction with running
      the Flask server.