def make_request(image): json_string = json.dumps({"shape": (CONFIG.IMAGE_HEIGHT, CONFIG.IMAGE_WIDTH), "cookie": CONFIG.HTTP_COOKIE}) data = bytes(json_string, "ascii") data += b"\n" #for easy separation data += image.tobytes() data = cipher.encrypt(data) files = {'data': data} try: r = requests.post(CONFIG.HTTP_SERVER_URL(), files=files, timeout=10) except Exception as e: logger.warning('Error communicating with Computational Server, ERR: %s' % str(e)) return None try: return r.json() except Exception as e: logger.warning('Error parsing json, ERR: %s' % str(e)) return None
def make_request(): r = requests.get(CONFIG.HTTP_SERVER_URL()) print(r.content)