-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.py
More file actions
53 lines (31 loc) · 1.08 KB
/
client.py
File metadata and controls
53 lines (31 loc) · 1.08 KB
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
import requests
import src.auth as auth
# url = "http://0.0.0.0:8000/login-register"
# login_reg_payload = {
# 'userid': "rick",
# 'password': "12345",
# 'action': "register",
# }
# def send_payload(payload):
# jwt_token = auth.encode(json_payload=payload)
# payload_to_send = {"payload": jwt_token}
# print(f"Payload sent: {payload_to_send}")
# response = requests.post(url, json=payload_to_send)
# print(f"Response status: {response.status_code}")
# print(f"Response body: {response.text}")
# return response
# print(send_payload(login_reg_payload))
import requests
# Replace with your actual FastAPI server URL and db_id
url = "http://localhost:8000/users/user_db_rick/add_contacts"
# List of image file paths to send
image_files = [
"20240625_154117.jpg"
]
# Prepare the multipart form-data
files = [("contact_images", (open(path, "rb"))) for path in image_files]
# Send the POST request
response = requests.post(url, files=files)
# Print response
print("Status Code:", response.status_code)
print("Response:", response.text)