Download scripts/check_brand.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_brand.py
- Command line
-
hf download hf://spaces/Mohansree/bsure-api/scripts/check_brand.py
-
curl -L -o check_brand.py https://huggingface.co/spaces/Mohansree/bsure-api/resolve/main/scripts/check_brand.py
1.5 kB
| import requests | |
| import json | |
| BASE_URL = "http://localhost:8000" | |
| def test_brand_features(): | |
| print("Testing Brand Portal API...") | |
| # 1. Ensure Data Seeded | |
| requests.post(f"{BASE_URL}/monetization/seed") | |
| # 2. Mock Login (Resolve Name to ID) | |
| # Since we can't fully simulate the frontend Logic here easily, we'll manually pick ID 2 (Nike) | |
| # The frontend logic finds ID 2 for "Nike". | |
| BRAND_ID = 2 | |
| print(f"\n1. Accessing Brand Dashboard for ID {BRAND_ID} (Nike)...") | |
| try: | |
| res = requests.get(f"{BASE_URL}/brand/{BRAND_ID}/dashboard") | |
| if res.status_code == 200: | |
| data = res.json() | |
| print(f"✅ Brand Name: {data['brand_name']}") | |
| print(f"✅ Total Clicks: {data['total_clicks']}") | |
| print(f"✅ GMV Generated: ${data['gmv_generated']}") | |
| print(f"✅ Active Products: {data['product_count']}") | |
| if data['products']: | |
| print(f" Top SKU: {data['products'][0]['name']}") | |
| else: | |
| print(f"❌ Failed to load dashboard: {res.status_code}") | |
| except Exception as e: | |
| print(f"❌ Connection failed: {e}") | |
| # 3. Test Brand Feed | |
| print(f"\n2. Fetching Brand Feed...") | |
| try: | |
| res = requests.get(f"{BASE_URL}/brand/{BRAND_ID}/feed") | |
| feed = res.json() | |
| print(f"✅ Feed Items: {len(feed)}") | |
| except Exception as e: | |
| print(f"❌ Connection failed: {e}") | |
| if __name__ == "__main__": | |
| test_brand_features() | |