Ejemplo n.º 1
0
 def get(self):
     task_hash_base64 = str(request.args.get("task_hash", "-1"))
     if task_hash_base64 != "-1":
         task_hash = base64_str_to_bytes(task_hash_base64)
         block_and_signature = blockchain_recorder.return_block_and_signature(task_hash, key_manager)
         block_and_signature_base64 = dic_bytes_content_to_base64(block_and_signature)
         return jsonify(block_and_signature_base64)
     else:
         all_blocks = blockchain_recorder.all_blocks
         all_blocks_base64 = []
         for block in all_blocks:
             all_blocks_base64.append(dic_bytes_content_to_base64(block))
         return jsonify(all_blocks_base64)
Ejemplo n.º 2
0
 def post(self):
     json_data = request.get_json(force=True)
     client_key = dic_base64_to_bytes(json_data)["client_key"]
     base64_return_value = dic_bytes_content_to_base64(key_manager.return_encrypted_keys_and_sign(client_key))
     #print(key_manager.client_key_map_server_key)
     #print(key_manager.return_encrypted_keys_and_sign(client_key))
     #print(len(key_manager.client_key_map_server_key))
     return jsonify(base64_return_value)
Ejemplo n.º 3
0
 def post_task(self, task_name: str, task_file_path: str):
     print("------Begin Posting Task------")
     request_json = json.dumps(dic_bytes_content_to_base64(self.client.generate_task(task_name, task_file_path)))
     print("Task Create Success. Task Info:")
     print_task(self.client.task_info[-1])
     task_post_request = requests.post(self.server_url + "/task", data = request_json)
     print("Response from Server:", task_post_request.json())
     np.save(os.path.join(self.saving_path, TASK_INFO_FILENAME), self.client.task_info)
     print("Local Task Info Update Success.")
     print("------Post Task Success------\n")