sahel-api / backend /scripts /test_api2.py
Mohamed-20's picture
Deploy backend to HF Spaces
1337ed3
Raw
History Blame Contribute Delete
779 Bytes
import urllib.request, json
# Test list all businesses
print("=== GET /businesses (list) ===")
try:
req = urllib.request.Request("http://localhost:8000/businesses")
resp = urllib.request.urlopen(req)
data = json.loads(resp.read())
print(f"OK - {len(data.get('businesses', []))} businesses")
except urllib.error.HTTPError as e:
print(f"Error {e.code}: {e.read().decode()}")
print()
print("=== GET /businesses/amoudou ===")
try:
req = urllib.request.Request("http://localhost:8000/businesses/amoudou")
resp = urllib.request.urlopen(req)
data = json.loads(resp.read())
print(f"OK - {data.get('name')}")
print(f"social_media: {data.get('social_media')}")
except urllib.error.HTTPError as e:
print(f"Error {e.code}: {e.read().decode()}")