Skip to content

Commit bd61f48

Browse files
committed
Spanish Translate
1 parent 568f7ef commit bd61f48

File tree

29 files changed

+501
-3
lines changed

29 files changed

+501
-3
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import requests
2+
3+
url = "https://assets.breatheco.de/apis/fake/sample/404-example.php"
4+
response = requests.get(url)
5+
6+
print("The response status is: "+str(response.status_code))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import requests
2+
3+
response = requests.get("https://assets.breatheco.de/apis/fake/sample/random-status.php")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import requests
2+
3+
url = "https://assets.breatheco.de/apis/fake/sample/random-status.php"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import requests
2+
3+
response = requests.get("https://assets.breatheco.de/apis/fake/sample/time.php")
4+
print(response.text)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import requests
2+
3+
# your code here
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import requests
2+
3+
# your code here
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import requests
2+
3+
# your code here
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import requests
2+
3+
# your code here
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import requests
2+
3+
def get_titles():
4+
# your code here
5+
return None
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import requests
2+
3+
def get_post_tags(post_id):
4+
# your code here
5+
return None
6+
7+
8+
print(get_post_tags(146))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import requests
2+
3+
def get_attachment_by_id(attachment_id):
4+
# your code here
5+
return None
6+
7+
print(get_attachment_by_id(137))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import requests
2+
3+
# your code here
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import requests
2+
3+
resp = requests.post("https://assets.breatheco.de/apis/fake/sample/save-project-json.php")
4+
print(resp.text)

bc.json

+142-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,144 @@
11
{
2-
"language": "python3"
2+
"port": 3000,
3+
"address": "localhost",
4+
"editor": "gitpod",
5+
"outputPath": "./.breathecode/dist",
6+
"publicPath": "/preview",
7+
"grading": "isolated",
8+
"ignoreRegex": null,
9+
"webpack_template": null,
10+
"disable_grading": false,
11+
"onCompilerSuccess": null,
12+
"language": "python3",
13+
"compiler": "python3",
14+
"tester": "pytest",
15+
"actions": [
16+
"run",
17+
"test",
18+
"reset"
19+
],
20+
"session": 3445355432462036000,
21+
"exercisesPath": "./exercises",
22+
"exercises": [
23+
{
24+
"slug": "01-hello-world",
25+
"title": "01-hello-world",
26+
"path": "exercises/01-hello-world",
27+
"translations": [
28+
"es",
29+
"us"
30+
]
31+
},
32+
{
33+
"slug": "01-what-is-a-request",
34+
"title": "01-what-is-a-request",
35+
"path": "exercises/01-what-is-a-request",
36+
"translations": [
37+
"es",
38+
"us"
39+
]
40+
},
41+
{
42+
"slug": "02-random-status",
43+
"title": "02-random-status",
44+
"path": "exercises/02-random-status",
45+
"translations": [
46+
"es",
47+
"us"
48+
]
49+
},
50+
{
51+
"slug": "03-response-body",
52+
"title": "03-response-body",
53+
"path": "exercises/03-response-body",
54+
"translations": [
55+
"es",
56+
"us"
57+
]
58+
},
59+
{
60+
"slug": "04-response-body-json",
61+
"title": "04-response-body-json",
62+
"path": "exercises/04-response-body-json",
63+
"translations": [
64+
"es",
65+
"us"
66+
]
67+
},
68+
{
69+
"slug": "05-project-name",
70+
"title": "05-project-name",
71+
"path": "exercises/05-project-name",
72+
"translations": [
73+
"es",
74+
"us"
75+
]
76+
},
77+
{
78+
"slug": "06-project-list",
79+
"title": "06-project-list",
80+
"path": "exercises/06-project-list",
81+
"translations": [
82+
"es",
83+
"us"
84+
]
85+
},
86+
{
87+
"slug": "07-project-list-image",
88+
"title": "07-project-list-image",
89+
"path": "exercises/07-project-list-image",
90+
"translations": [
91+
"es",
92+
"us"
93+
]
94+
},
95+
{
96+
"slug": "08-blog-post-author",
97+
"title": "08-blog-post-author",
98+
"path": "exercises/08-blog-post-author",
99+
"translations": [
100+
"us"
101+
]
102+
},
103+
{
104+
"slug": "09-array-of-blog-titles",
105+
"title": "09-array-of-blog-titles",
106+
"path": "exercises/09-array-of-blog-titles",
107+
"translations": [
108+
"us"
109+
]
110+
},
111+
{
112+
"slug": "10-get_post_tags",
113+
"title": "10-get_post_tags",
114+
"path": "exercises/10-get_post_tags",
115+
"translations": [
116+
"us"
117+
]
118+
},
119+
{
120+
"slug": "11-get_attachment_by_id",
121+
"title": "11-get_attachment_by_id",
122+
"path": "exercises/11-get_attachment_by_id",
123+
"translations": [
124+
"us"
125+
]
126+
},
127+
{
128+
"slug": "12-post-request",
129+
"title": "12-post-request",
130+
"path": "exercises/12-post-request",
131+
"translations": [
132+
"us"
133+
]
134+
},
135+
{
136+
"slug": "13-post-request-body",
137+
"title": "13-post-request-body",
138+
"path": "exercises/13-post-request-body",
139+
"translations": [
140+
"us"
141+
]
142+
}
143+
]
3144
}

exercises/01-hello-world/README.es.md

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Python API Requests
2+
3+
Python Requests es el paquete más popular para consumir API y hacer solicitudes HTTP.
4+
5+
Aquí aprenderás:
6+
7+
1. Cómo hacer solicitudes GET.
8+
2. Cómo obtener propiedades de una data e información.
9+
3. Cómo configurar request headers.
10+
4. Cómo configurar request content-type.
11+
5. Cómo hacer solicitudes POST.
12+
13+
Haga click en el botón `next →` en la esquina superior derecha para continuar.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# 02 Creando una solicitud (request)
2+
3+
Python tiene un [paquete de solicitud (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+
Cambie la variable URL para que solicite:
15+
16+
```bash
17+
https://assets.breatheco.de/apis/fake/sample/hello.php
18+
```
19+
20+
Nota: La consola debe imprimir un código de estado 200.
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# `02` Manejar el Status de Respuesta
2+
3+
La siguiente solicitud GET siempre devuelve un código de status diferente, nunca se sabe qué respuesta está recibiendo del servidor.
4+
5+
## 📝Instrucciones
6+
7+
Crea una condición para imprimir en la consola los siguientes mensajes según el status de respuesta:
8+
9+
| Status | Message |
10+
| ----- | ----- |
11+
| 404 | The URL you asked is not found |
12+
| 503 | Unavailable right now |
13+
| 200 | Everything went perfect |
14+
| 400 | Something is wrong on the request params |
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# `03` Respuesta en Body
2+
3+
Haga clic en este enlace para ver la respuesta que esta solicitud GET está dando en el body:
4+
[https://assets.breatheco.de/apis/fake/sample/random-status.php](https://assets.breatheco.de/apis/fake/sample/random-status.php)
5+
6+
Ahora, si deseas obtener ese body como respuesta (texto), todo lo que tiene que hacer es:
7+
```py
8+
# plain text
9+
print(response.text)
10+
```
11+
12+
# 📝 Instrucciones
13+
14+
Imprime en la consola la the responde body solo para solicitudes 200, para el resto imprima "Something went wrong".
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# `04` Respuesta JSON
2+
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+
5+
# 📝 Instrucciones
6+
7+
El siguiente endpoint devuelve la hora actual en un formato JSON cada vez que se solicita utilizando el método GET.
8+
9+
| | |
10+
| --- | --- |
11+
| method | GET |
12+
| endpoint | https://assets.breatheco.de/apis/fake/sample/time.php |
13+
| content-type | application/json |
14+
15+
Response body:
16+
17+
```python
18+
{
19+
"hours": "07",
20+
"minutes": "29",
21+
"seconds": "35"
22+
}
23+
```
24+
25+
Haga una solicitud GET a ese endpoint e imprima la hora en la consola con este formato:
26+
27+
```bash
28+
Current time: 17 hrs 06 min and 23 sec
29+
```
30+
31+
## 💡Pista
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`
36+
+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# `05` Nombre de Proyecto
2+
3+
El siguiente endpoint es ideal para recuperar proyectos de estudiantes:
4+
5+
GET [https://assets.breatheco.de/apis/fake/sample/project1.php](https://assets.breatheco.de/apis/fake/sample/project1.php)
6+
7+
```json
8+
{
9+
"name": "Coursera eLearning",
10+
"thumb": "https://unsplash.it/450/320?image=178",
11+
"description": "The coolest elarning site on the planet",
12+
"images": [
13+
"https://unsplash.it/450/320?image=178",
14+
"https://unsplash.it/450/320?image=179",
15+
"https://unsplash.it/450/320?image=180",
16+
"https://unsplash.it/450/320?image=181"
17+
]
18+
}
19+
```
20+
21+
# 📝 Instrucciones
22+
23+
Llama al endpoint e imprime el nombre del proyecto en el terminal (solo el nombre del proyecto)
24+
25+
Example output:
26+
```bash
27+
Coursera eLearning
28+
```
29+
30+
## 💡Pista
31+
32+
1. Ejercicio similar al anterior.
33+
2. Haz una solicitud GET al endpoint.
34+
3. Usa el [metodo .json()](https://www.w3schools.com/python/ref_requests_response.asp) para obtener el response body como un diccionario (igual que lo hizo en el último ejercicio).
35+
4. Imprime el nombre del proyecto, puedes acceder al nombre de la propiedad en el diccionario de respuestas.
36+

0 commit comments

Comments
 (0)