Download scripts/check_size.py from Mohansree/bsure-api: direct link, hf CLI and curl.
- Browser
- Download file 1.5 kB
-
https://huggingface.co/spaces/Mohansree/bsure-api/resolve/main/scripts/check_size.py
- Command line
-
hf download hf://spaces/Mohansree/bsure-api/scripts/check_size.py
-
curl -L -o check_size.py https://huggingface.co/spaces/Mohansree/bsure-api/resolve/main/scripts/check_size.py
1.5 kB
| 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() | |