الملفات
ghaymah-exam-abdelaziz-sre/q5-mithal-monitor/monitor.py
2026-07-27 20:03:38 -04:00

26 أسطر
508 B
Python

import requests
import time
URL = "http://127.0.0.1:8000/health"
while True:
try:
start = time.time()
response = requests.get(URL)
end = time.time()
response_time = round((end - start) * 1000, 2)
print("=" * 40)
print("Status Code :", response.status_code)
print("Application :", "UP")
print("Response Time:", response_time, "ms")
except Exception:
print("=" * 40)
print("Application : DOWN")
time.sleep(30)