You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Python tiene integrado un [paquete de solicitudes (*requests package*)](https://requests.readthedocs.io/en/master/) eso permite a los desarrolladores crear solicitudes HTTP con bastante facilidad.
4
+
5
+
Así es como en Python hacemos una solicitud HTTP GET:
6
+
7
+
```python
8
+
response = requests.get('<destination url>')
9
+
print(response.status_code)
10
+
```
11
+
12
+
## 📝 Instrucciones:
13
+
14
+
Actualiza la variable `url` para que solicite a esta dirección:
Copy file name to clipboardExpand all lines: exercises/04-response-body-json/README.es.md
+7-7
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,8 @@
1
-
# `04`Respuesta JSON
1
+
# `04`Response JSON
2
2
3
3
Pero tener una respuesta basada en texto no es muy útil, es por eso que las API normalmente responden en formato CSV, JSON, YAML o XML.
4
4
5
-
# 📝 Instrucciones
5
+
##📝 Instrucciones:
6
6
7
7
El siguiente endpoint devuelve la hora actual en un formato JSON cada vez que se solicita utilizando el método GET.
8
8
@@ -22,15 +22,15 @@ Response body:
22
22
}
23
23
```
24
24
25
-
Haga una solicitud GET a ese endpoint e imprima la hora en la consola con este formato:
25
+
1. Haz una solicitud GET a ese endpoint e imprime la hora en la consola con este formato:
26
26
27
27
```bash
28
28
Current time: 17 hrs 06 min and 23 sec
29
29
```
30
30
31
-
## 💡Pista
31
+
## 💡 Pistas:
32
32
33
-
1. Usa el [metodo .json()](https://www.w3schools.com/python/ref_requests_response.asp) para obtener el response body como un diccionario y almacenarlo en una variable
34
-
2. Obtenga las propiedades `horas`,` minutos` y `segundos` del diccionario
35
-
3. Concatenar todo de esta manera: `Hora actual: 17 h 06 min y 23 seg`
33
+
+ Usa el [metodo .json()](https://www.w3schools.com/python/ref_requests_response.asp) para obtener el response body como un diccionario y almacenarlo en una variable.
34
+
+ Obtenga las propiedades `hours`, `minutes` y `seconds` del diccionario.
35
+
+ Concatenar todo de esta manera: `Hora actual: 17 h 06 min y 23 seg`.
Copy file name to clipboardExpand all lines: exercises/04-response-body-json/README.md
+8-8
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,8 @@
1
1
# `04` Response JSON
2
2
3
-
But having a text based response is not very useful, that is why API's normally respond in CSV, JSON, YAML or XML format.
3
+
But having a text based response is not very useful, that is why APIs normally respond in CSV, JSON, YAML or XML format.
4
4
5
-
# 📝 Instructions
5
+
##📝 Instructions:
6
6
7
7
The following endpoint returns the current time in a JSON format every time it is requested using the GET method.
8
8
@@ -22,15 +22,15 @@ Response body:
22
22
}
23
23
```
24
24
25
-
Please do a GET request to that endpoint and print the time on the console with this format:
25
+
1.Please do a GET request to that endpoint and print the time on the console with this format:
26
26
27
-
```bash
27
+
```text
28
28
Current time: 17 hrs 06 min and 23 sec
29
29
```
30
30
31
-
## 💡Hint
31
+
## 💡 Hints:
32
32
33
-
1. Use the [.json() method](https://www.w3schools.com/python/ref_requests_response.asp) to get the response body as a dictionary and store it in a variable
34
-
2. Get the `hours`, `minutes` and `seconds` properties from the dictionary
35
-
3. Concatenate everything together like this: `Current time: 17 hrs 06 min and 23 sec`
33
+
+ Use the [.json() method](https://www.w3schools.com/python/ref_requests_response.asp) to get the response body as a dictionary and store it in a variable.
34
+
+ Get the `hours`, `minutes` and `seconds` properties from the dictionary.
35
+
+ Concatenate everything together like this: `Current time: 17 hrs 06 min and 23 sec`.
0 commit comments