if status_code != 200
This commit is contained in:
7
init.py
7
init.py
@@ -4,8 +4,11 @@ from time import sleep
|
|||||||
|
|
||||||
while True:
|
while True:
|
||||||
req = requests.get("http://ipinfo.io/ip")
|
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
|
# existe archivo con la antigua ip
|
||||||
file_exists = exists("old_ip.txt")
|
file_exists = exists("old_ip.txt")
|
||||||
if not file_exists:
|
if not file_exists:
|
||||||
@@ -18,7 +21,7 @@ while True:
|
|||||||
# si existe y esta vacia
|
# si existe y esta vacia
|
||||||
with open("old_ip.txt", "r") as f:
|
with open("old_ip.txt", "r") as f:
|
||||||
contenido = f.read()
|
contenido = f.read()
|
||||||
if contenido == '':
|
if contenido == "":
|
||||||
f = open("old_ip.txt", "w")
|
f = open("old_ip.txt", "w")
|
||||||
f.write("ip vacia")
|
f.write("ip vacia")
|
||||||
f.close()
|
f.close()
|
||||||
|
|||||||
Reference in New Issue
Block a user