for_ghost = '0 '+str(disp[0])+' '+str(disp[1])+'\n' if dist(pen_cords, cur_cords) > 10: for_ghost = '1 1 0\n' + for_ghost + '1 0 0\n' ghost_data += for_ghost else: if line[0:5] == '1 1 0': continue cords = line.strip().split('*')[1].split(' ') pen_cords = (int(cords[0]), int(cords[1])) ghost_data += line.split('*')[0] + '\n' ghost_data += '1 1 0\n' requests.post(GHOST_ADDRESS, ghost_data) f.close() self.ocrres = asyncio.Future() res = yield from self.ocrres return Response(status=200, body=res.encode()) # Response from the Ghost Server which contains the recognized string. @get(path='/ocrres/{res}') def req5(self, request: Request): self.ocrres.set_result(request.match_info.get('res')) return Response(status=200, body='thanx'.encode()) if __name__ == '__main__': http = TaggerService(MY_URL, 4501) Host.configure('TaggerService') Host.attach_http_service(http) Host.ronin = True Host.run()