Spaces:
Sleeping
Sleeping
| import os | |
| import requests | |
| def is_huggingface_endpoint(endpoint): | |
| if not endpoint: | |
| return False | |
| try: | |
| # Send a simple GET or POST request to the endpoint | |
| headers = {"Authorization": "Bearer YOUR_HUGGINGFACE_API_KEY"} # Replace with your Hugging Face API key if needed | |
| response = requests.get(endpoint, headers=headers) | |
| if response.status_code == 200: | |
| # Check if the response contains Hugging Face-specific data | |
| if "model" in response.json(): | |
| return True | |
| elif response.status_code == 404: | |
| print("Endpoint not found, make sure the endpoint is correct.") | |
| else: | |
| print(f"Error: Received status code {response.status_code}") | |
| return False | |
| except requests.exceptions.RequestException as e: | |
| print(f"Request failed: {e}") | |
| return False | |
| ''' | |
| # Test the endpoint | |
| if is_huggingface_endpoint(my_id): | |
| print("This is a Hugging Face Inference Endpoint.") | |
| else: | |
| print("This is NOT a Hugging Face Inference Endpoint.") | |
| ''' | |