diff --git a/index.py b/index.py index 35f677f..d97ee65 100644 --- a/index.py +++ b/index.py @@ -11,6 +11,9 @@ with open("config.toml", "rb") as f: app = Flask("velping") logging.disable(logging.CRITICAL) +http = requests.Session() +http.headers["User-Agent"] = "velping" + uptime = {} @@ -25,7 +28,7 @@ def handle_service_status( and config["ntfy"]["enabled"] and down ): - requests.post( + http.post( url=f"https://{config['ntfy']['server']}/{config['ntfy']['topic']}", data=f"Service {service_name} is offline", ) @@ -34,7 +37,7 @@ def handle_service_status( and config["ntfy"]["enabled"] and not down ): - requests.post( + http.post( url=f"https://{config['ntfy']['server']}/{config['ntfy']['topic']}", data=f"Service {service_name} is online", ) @@ -101,7 +104,7 @@ def http_ping(service): while True: print(f"[I] Pinging {service['name']}") try: - resp = requests.get( + resp = http.get( url=address, timeout=timeout, )