Spaces:
Sleeping
Sleeping
Download test_api.py from parthraninga/Safe-Space: direct link, hf CLI and curl.
- Browser
- Download file 618 Bytes
-
https://huggingface.co/spaces/parthraninga/Safe-Space/resolve/main/test_api.py
- Command line
-
hf download hf://spaces/parthraninga/Safe-Space/test_api.py
-
curl -L -o test_api.py https://huggingface.co/spaces/parthraninga/Safe-Space/resolve/main/test_api.py
618 Bytes
| import requests | |
| # Test the heatmap endpoint | |
| response = requests.get('http://localhost:8000/api/threats/heatmap', timeout=15) | |
| print('Status:', response.status_code) | |
| if response.status_code == 200: | |
| data = response.json() | |
| cities = data.get('heatmap_data', []) | |
| print(f'Total cities: {len(cities)}') | |
| for city in cities[:3]: | |
| print(f"{city['city']}: {city['threatCount']} threats ({city['threatLevel']})") | |
| print(f" High: {city['highRiskCount']}, Medium: {city['mediumRiskCount']}, Low: {city['lowRiskCount']}") | |
| print() | |
| else: | |
| print('Error:', response.text) | |