File size: 1,504 Bytes
af1d8cd | 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 | import requests
import json
BASE_URL = "http://localhost:8000"
def test_size_api():
print("Testing Size Translation API...")
# 1. Update Measurements
print("\n1. Updating User Measurements...")
measurements = {
"user_id": 1,
"height_cm": 180,
"weight_kg": 75,
"chest_cm": 100,
"waist_cm": 85,
"hip_cm": 95,
"preferred_fit": "regular"
}
try:
res = requests.post(f"{BASE_URL}/size/measurements", json=measurements)
if res.status_code == 200:
print("β
Measurements updated successfully!")
print(res.json())
else:
print(f"β Failed to update measurements: {res.status_code}")
print(res.text)
return
except Exception as e:
print(f"β Connection failed: {e}")
return
# 2. Get Recommendation
print("\n2. Getting Size Recommendation (Nike Top)...")
payload = {
"user_id": 1,
"brand": "Nike",
"category": "top"
}
try:
res = requests.post(f"{BASE_URL}/size/recommend", json=payload)
if res.status_code == 200:
print("β
Recommendation received!")
print(json.dumps(res.json(), indent=2))
else:
print(f"β Failed to get recommendation: {res.status_code}")
print(res.text)
except Exception as e:
print(f"β Connection failed: {e}")
if __name__ == "__main__":
test_size_api()
|