From 512a538a1e22619688ecb04b14a6d3ba3e925906 Mon Sep 17 00:00:00 2001 From: clonbg Date: Thu, 1 Feb 2024 11:56:22 +0100 Subject: [PATCH] if status_code != 200 --- init.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/init.py b/init.py index 845109c..78f26d6 100644 --- a/init.py +++ b/init.py @@ -4,8 +4,11 @@ from time import sleep while True: req = requests.get("http://ipinfo.io/ip") - ip = req.text + while int(req.status_code) != 200: + sleep(60) + req = requests.get("http://ipinfo.io/ip") + ip = req.text # existe archivo con la antigua ip file_exists = exists("old_ip.txt") if not file_exists: @@ -18,7 +21,7 @@ while True: # si existe y esta vacia with open("old_ip.txt", "r") as f: contenido = f.read() - if contenido == '': + if contenido == "": f = open("old_ip.txt", "w") f.write("ip vacia") f.close()