الملفات

22 أسطر
464 B
Python

import time
import requests
URL = "http://localhost:5000/health"
while True:
start = time.time()
try:
response = requests.get(URL, timeout=5)
response_time = (time.time() - start) * 1000
print(
f"[OK] Status: {response.status_code} | "
f"Response Time: {response_time:.2f} ms"
)
except requests.exceptions.RequestException:
print("[DOWN] Service is unavailable")
time.sleep(30)