# ============================================================ # PhishGuard AI - keep_alive.py # Keeps your Render.com server awake 24/7. # # From architecture doc 5.3: # Render free tier sleeps after 15 min of inactivity. # This pings GET /health every 14 min to prevent that. # # WHERE TO RUN: # - On a second laptop / old computer # - On your phone using Termux (free Android app) # - On a friend's computer # - On your own laptop in a separate terminal (less ideal) # # HOW TO RUN: # python keep_alive.py # (keep this terminal window open — never close it) # ============================================================ import time import requests import datetime # !! CHANGE THIS to your actual Render URL !! API_URL = "https://YOUR-APP-NAME.onrender.com/health" INTERVAL = 14 * 60 # 14 minutes in seconds print("=" * 50) print("PhishGuard Keep-Alive Script") print("=" * 50) print(f"Pinging: {API_URL}") print(f"Every: 14 minutes") print(f"Started: {datetime.datetime.now():%Y-%m-%d %H:%M:%S}") print("\nDO NOT close this window!") print("Press Ctrl+C to stop.\n") ping_count = 0 while True: try: r = requests.get(API_URL, timeout=15) ping_count += 1 status = "OK" if r.status_code == 200 else f"ERROR {r.status_code}" print(f"[{datetime.datetime.now():%H:%M:%S}] Ping #{ping_count} → {status}") except requests.exceptions.ConnectionError: print(f"[{datetime.datetime.now():%H:%M:%S}] Connection failed — server might be waking up...") except Exception as e: print(f"[{datetime.datetime.now():%H:%M:%S}] Error: {e}") time.sleep(INTERVAL)