Start Python web server and return control to app Start Python web server and return control to app flask flask

Start Python web server and return control to app


You can start in a new thread. You should set the daemon flag so that Ctrl+C can end the script.

class ServerThread(threading.Thread):  def __init__(self):    threading.Thread.__init__(self)  def run(self):    app.run(      port=7777,      host='localhost'    )if '__main__'==__name__:  logging.getLogger().addHandler(logging.StreamHandler())  thread = ServerThread()  thread.daemon = True  thread.start()