binoua commited on
Commit
59e7a3a
1 Parent(s): a35e3b6

chore: using a database for keys

Browse files
Files changed (2) hide show
  1. handler.py +1 -1
  2. play_with_endpoint.py +3 -1
handler.py CHANGED
@@ -52,7 +52,7 @@ class EndpointHandler:
52
  elif method == "inference":
53
 
54
  uid = data.pop("uid", data)
55
- assert uid in self.key_database.keys()
56
 
57
  # Get inputs
58
  encrypted_inputs = from_json(data.pop("encrypted_inputs", data))
 
52
  elif method == "inference":
53
 
54
  uid = data.pop("uid", data)
55
+ assert uid in self.key_database.keys(), f"{uid} not in DB"
56
 
57
  # Get inputs
58
  encrypted_inputs = from_json(data.pop("encrypted_inputs", data))
play_with_endpoint.py CHANGED
@@ -32,6 +32,8 @@ headers = {
32
 
33
  def query(payload):
34
  response = requests.post(API_URL, headers=headers, json=payload)
 
 
35
  return response.json()
36
 
37
 
@@ -53,8 +55,8 @@ payload = {
53
  "method": "save_key",
54
  }
55
 
56
- print("Storing the key in the database")
57
  uid = query(payload)
 
58
 
59
  # Test the handler
60
  nb_good = 0
 
32
 
33
  def query(payload):
34
  response = requests.post(API_URL, headers=headers, json=payload)
35
+ print(f"{response=}")
36
+ print(f"{response.json()=}")
37
  return response.json()
38
 
39
 
 
55
  "method": "save_key",
56
  }
57
 
 
58
  uid = query(payload)
59
+ print(f"Storing the key in the database under {uid=}")
60
 
61
  # Test the handler
62
  nb_good = 0