File size: 900 Bytes
b3cb0b5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import requests
import time
from datetime import datetime

URL = "https://superbryn-task-backend.onrender.com/health"
INTERVAL = 30  # seconds

def ping_server():
    print(f"🚀 Starting pinger for {URL} every {INTERVAL} seconds...")
    while True:
        try:
            timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
            response = requests.get(URL, timeout=10)
            
            if response.status_code == 200:
                print(f"[{timestamp}] ✅ Success: {response.status_code} - {response.text}")
            else:
                print(f"[{timestamp}] ⚠️ Warning: Status {response.status_code} - {response.text}")
                
        except requests.exceptions.RequestException as e:
            print(f"[{timestamp}] ❌ Error: {e}")
            
        time.sleep(INTERVAL)

if __name__ == "__main__":
    ping_server()