test / test_api.py
hibatorrahmen's picture
added fixes
1d14811
import requests
import json
# Base URL of your Space
BASE_URL = "https://urjob-test.hf.space"
# The JWT token from your logs
HF_SIGN = "eyJhbGciOiJFZERTQSJ9.eyJyZWFkIjp0cnVlLCJwZXJtaXNzaW9ucyI6eyJyZXBvLmNvbnRlbnQucmVhZCI6dHJ1ZX0sIm9uQmVoYWxmT2YiOnsia2luZCI6InVzZXIiLCJfaWQiOiI2N2FiYzRmMDQxMjM1ODI0NDQyNDQwNmUiLCJ1c2VyIjoiaGliYXRvcnJhaG1lbiIsInNlc3Npb25JZCI6IjY4MmM0MjUyZTE3MzJjNzZiNGM1MjdlOCJ9LCJpYXQiOjE3NDc5NTMxODMsInN1YiI6Ii9zcGFjZXMvdXJqb2IvdGVzdCIsImV4cCI6MTc0ODAzOTU4MywiaXNzIjoiaHR0cHM6Ly9odWdnaW5nZmFjZS5jbyJ9.9Ukimz1w0j8hAohN7HxGbadMPD0FZpDMYFuSHTxFByOA8HtMG3U-HuZNs2sSo3reqnb3gkKgZx0d_99VaWmFAQ"
def test_root():
"""Test the root endpoint with HF Space sign"""
params = {
"__sign": HF_SIGN
}
response = requests.get(f"{BASE_URL}/", params=params)
print("\nRoot Endpoint (/) Response:", response.status_code)
print(response.json() if response.ok else response.text)
def test_basic_health():
"""Test the basic health endpoint"""
params = {
"__sign": HF_SIGN
}
response = requests.get(f"{BASE_URL}/health", params=params)
print("\nBasic Health Endpoint (/health) Response:", response.status_code)
print(response.json() if response.ok else response.text)
def test_api_health():
"""Test the API health endpoint with HF Space sign"""
params = {
"__sign": HF_SIGN
}
response = requests.get(f"{BASE_URL}/health/api", params=params)
print("\nAPI Health Endpoint (/health/api) Response:", response.status_code)
print(response.json() if response.ok else response.text)
if __name__ == "__main__":
print("Testing API endpoints...")
test_root()
test_basic_health()
test_api_health()