Skip to content

Commit 4651ce3

Browse files
authored
Update avcenal.py
Añado el control en al parte básica del ejercicio por si da un status_code diferente de 200
1 parent 03287ff commit 4651ce3

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Roadmap/20 - PETICIONES HTTP/python/avcenal.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@
1010

1111
url = "https://retosdeprogramacion.com"
1212
response = get(url)
13-
#print(response.content.decode("utf-8").replace(">",">\n")) se podría dar formato a los bytes que recoge la llamada
14-
print(response.content)
13+
if response.status_code == 200:
14+
print(response.text.replace(">",">\n")) #doy formato a la respuesta
15+
else:
16+
print(f"Error, código: {response.status_code}")
1517

1618
"""
1719
* DIFICULTAD EXTRA (opcional):

0 commit comments

Comments
 (0)