def handle_checkConnection(res): httpd.allConnected = res def handle_updateSelectedChar(res): result=json.loads(res) httpd.allConnected = result['selectedChar'] httpd.availChar =result['availChar'] def handle_partnerMoved(res): httpd.movingChar = res # self.getRes(self.path+'/'+httpd.myChar+'/'+httpd.movingChar) httpd = HTTPServer(('localhost', 12345), SimpleHTTPRequestHandler) wsClient = WSClient() httpd.availChar = 'x' httpd.myChar = 'x' httpd.movingChar = 'x' httpd.dice = 0 httpd.allConnected = 0 httpd.availPlayer = '' httpd.requestFrom = 0 httpd.isNameOk = 0 httpd.myName = '' httpd.oppo='' threading.Thread(target=httpd.serve_forever).start() wsClient.loop = asyncio.get_event_loop() wsClient.loop.run_until_complete(wsClient.listen())