Spaces:
Sleeping
Sleeping
Create checks/endpoint_check.py
Browse files- checks/endpoint_check.py +16 -0
checks/endpoint_check.py
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import requests
|
| 2 |
+
import sys
|
| 3 |
+
|
| 4 |
+
def is_huggingface_endpoint(endpoint: str):
|
| 5 |
+
try:
|
| 6 |
+
headers = {"Authorization": "Bearer YOUR_HUGGINGFACE_API_KEY"}
|
| 7 |
+
response = requests.get(endpoint, headers=headers)
|
| 8 |
+
|
| 9 |
+
if response.status_code == 200 and "model" in response.json():
|
| 10 |
+
return True
|
| 11 |
+
else:
|
| 12 |
+
print("This is NOT a Hugging Face Inference Endpoint.")
|
| 13 |
+
return False
|
| 14 |
+
except requests.exceptions.RequestException as e:
|
| 15 |
+
print(f"Request failed: {e}")
|
| 16 |
+
return False
|