if status_code != 200

This commit is contained in:
2024-02-01 11:56:22 +01:00
parent aa248f67b6
commit 512a538a1e

View File

@@ -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()