Download scripts/verify_all.py from Mohansree/bsure-api: direct link, hf CLI and curl.
- Browser
- Download file 2.85 kB
-
https://huggingface.co/spaces/Mohansree/bsure-api/resolve/main/scripts/verify_all.py
- Command line
-
hf download hf://spaces/Mohansree/bsure-api/scripts/verify_all.py
-
curl -L -o verify_all.py https://huggingface.co/spaces/Mohansree/bsure-api/resolve/main/scripts/verify_all.py
2.85 kB
| import requests | |
| import json | |
| import sys | |
| BASE_URL = "http://localhost:8000" | |
| def log(msg, success=True): | |
| icon = "✅" if success else "❌" | |
| print(f"{icon} {msg}") | |
| def verify_system(): | |
| print("🚀 BSURE SYSTEM DIAGNOSTIC 🚀\n") | |
| # 1. API Health | |
| try: | |
| res = requests.get(f"{BASE_URL}/health") | |
| if res.status_code == 200: | |
| log("API Backend is ONLINE") | |
| else: | |
| log("API Backend is OFFLINE", False) | |
| return | |
| except: | |
| log("API Backend Unreachable", False) | |
| return | |
| # 2. Wardrobe & Auto-Tagging | |
| print("\n--- 👗 Wardrobe & AI ---") | |
| try: | |
| # Check if we can fetch wardrobe (assuming user 1 exists from seeding) | |
| res = requests.get(f"{BASE_URL}/wardrobe/1") | |
| if res.status_code == 200: | |
| items = res.json() | |
| log(f"Wardrobe Fetch Success ({len(items)} items found)") | |
| else: | |
| log("Wardrobe Fetch Failed", False) | |
| except Exception as e: | |
| log(f"Wardrobe Error: {e}", False) | |
| # 3. Size Translation | |
| print("\n--- 📏 Size Intelligence ---") | |
| try: | |
| payload = {"user_id": 1, "brand": "Nike", "category": "top"} | |
| res = requests.post(f"{BASE_URL}/size/recommend", json=payload) | |
| data = res.json() | |
| if "recommended_size" in data: | |
| log(f"Size Engine Working (Rec: {data['recommended_size']}, Conf: {data['confidence_score']})") | |
| else: | |
| log("Size Engine returned invalid data", False) | |
| except Exception as e: | |
| log(f"Size Engine Error: {e}", False) | |
| # 4. Monetization | |
| print("\n--- 💰 Monetization System ---") | |
| try: | |
| # Seed first to be sure | |
| requests.post(f"{BASE_URL}/monetization/seed") | |
| # Check Stats | |
| res = requests.get(f"{BASE_URL}/monetization/dashboard") | |
| stats = res.json() | |
| log(f"Revenue Dashboard Active (Total: ${stats['total_revenue']})") | |
| # Check Products | |
| res = requests.get(f"{BASE_URL}/monetization/products") | |
| prods = res.json() | |
| if len(prods) > 0: | |
| log(f"Affiliate Catalog Loaded ({len(prods)} products)") | |
| else: | |
| log("Affiliate Catalog Empty", False) | |
| except Exception as e: | |
| log(f"Monetization Error: {e}", False) | |
| # 5. Brand Portal (B2B) | |
| print("\n--- 🤝 Brand Portal ---") | |
| try: | |
| # Attempt to access Nike dashboard (ID 2) | |
| res = requests.get(f"{BASE_URL}/brand/2/dashboard") | |
| if res.status_code == 200: | |
| b_data = res.json() | |
| log(f"Brand Portal Active for {b_data['brand_name']}") | |
| else: | |
| log("Brand Portal Failed", False) | |
| except Exception as e: | |
| log(f"Brand Portal Error: {e}", False) | |
| print("\n✅ DIAGNOSTIC COMPLETE") | |
| if __name__ == "__main__": | |
| verify_system() | |