-
Notifications
You must be signed in to change notification settings - Fork 0
/
client_test.py
68 lines (49 loc) · 1.52 KB
/
client_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import requests
import json
import hashlib
from vbl_aquarium.models.dock import *
# # Define headers (if needed)
headers = {
"Content-Type": "application/json"
}
def hash256(password):
return hashlib.sha256(password.encode()).hexdigest()
# Define the API endpoint URL
api_url = "http://localhost:5000/create/dan_bucket"
data = BucketModel(
token = "c503675a-506c-48c0-9b5e-5265e8260a06",
password = hash256("password")
)
print(hash256("password"))
response = requests.post(api_url, data=data.to_string(), headers=headers)
# Check the response
if response.status_code == 201:
print(response.text)
else:
print("Error:", response.status_code, response.text)
## Create some real data
api_url = f'http://localhost:5000/upload/dan_bucket/neuron/n1'
# # Define the data to be sent in the PUT request
data = UploadModel(
data="{"position": [1,2,3]}",
password=hash256("password")
)
# # Convert the data to a JSON string
json_data = json.dumps(data)
# # Send the PUT request
response = requests.put(api_url, data=data.to_string(), headers=headers)
# Check the response
if response.status_code == 201:
print(response.text)
else:
print("Error:", response.status_code, response.text)
## Get your data back
api_url = f'http://localhost:5000/dan_bucket/neuron/n1'
data = DownloadModel(
password=hash256("password")
)
response = requests.get(api_url, data=data.to_string(), headers=headers)
if response.status_code == 201:
print(response.text)
else:
print("Error:", response.status_code, response.text)