Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 0ce440a

Browse files
committed
ejercicio 5
1 parent bb1e695 commit 0ce440a

File tree

5 files changed

+206
-5
lines changed

5 files changed

+206
-5
lines changed

‎bc.json

Lines changed: 181 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,184 @@
11
{
2+
"port": 3000,
3+
"address": "https://blue-mandrill-l01lbybf.ws-us03.gitpod.io",
4+
"editor": "gitpod",
5+
"configPath": {
6+
"config": "bc.json",
7+
"base": ".learn",
8+
"exercises": "./exercises",
9+
"output": ".learn/dist"
10+
},
11+
"outputPath": "./.learn/dist",
12+
"publicPath": "/preview",
13+
"grading": "isolated",
14+
"ignoreRegex": null,
15+
"webpack_template": null,
16+
"disable_grading": false,
17+
"onCompilerSuccess": null,
218
"language": "python3",
3-
"repository": "https://github.com/4GeeksAcademy/python-http-requests-api-tutorial-exercises"
19+
"compiler": "python3",
20+
"tester": "pytest",
21+
"actions": [
22+
"run",
23+
"test",
24+
"reset"
25+
],
26+
"repository": "https://github.com/4GeeksAcademy/python-http-requests-api-tutorial-exercises",
27+
"session": 4159901724455659000,
28+
"exercises": [
29+
{
30+
"slug": "01-hello-world",
31+
"title": "01-hello-world",
32+
"done": false,
33+
"path": "exercises/01-hello-world",
34+
"translations": [
35+
"es",
36+
"us"
37+
],
38+
"graded": false
39+
},
40+
{
41+
"slug": "01-what-is-a-request",
42+
"title": "01-what-is-a-request",
43+
"done": true,
44+
"path": "exercises/01-what-is-a-request",
45+
"translations": [
46+
"es",
47+
"us"
48+
],
49+
"graded": true
50+
},
51+
{
52+
"slug": "02-random-status",
53+
"title": "02-random-status",
54+
"done": true,
55+
"path": "exercises/02-random-status",
56+
"translations": [
57+
"es",
58+
"us"
59+
],
60+
"graded": true
61+
},
62+
{
63+
"slug": "03-response-body",
64+
"title": "03-response-body",
65+
"done": true,
66+
"path": "exercises/03-response-body",
67+
"translations": [
68+
"es",
69+
"us"
70+
],
71+
"graded": true
72+
},
73+
{
74+
"slug": "04-response-body-json",
75+
"title": "04-response-body-json",
76+
"done": true,
77+
"path": "exercises/04-response-body-json",
78+
"translations": [
79+
"es",
80+
"us"
81+
],
82+
"graded": true
83+
},
84+
{
85+
"slug": "05-project-name",
86+
"title": "05-project-name",
87+
"done": false,
88+
"path": "exercises/05-project-name",
89+
"translations": [
90+
"es",
91+
"us"
92+
],
93+
"graded": true
94+
},
95+
{
96+
"slug": "06-project-list",
97+
"title": "06-project-list",
98+
"done": false,
99+
"path": "exercises/06-project-list",
100+
"translations": [
101+
"es",
102+
"us"
103+
],
104+
"graded": true
105+
},
106+
{
107+
"slug": "07-project-list-image",
108+
"title": "07-project-list-image",
109+
"done": false,
110+
"path": "exercises/07-project-list-image",
111+
"translations": [
112+
"es",
113+
"us"
114+
],
115+
"graded": true
116+
},
117+
{
118+
"slug": "08-blog-post-author",
119+
"title": "08-blog-post-author",
120+
"done": false,
121+
"path": "exercises/08-blog-post-author",
122+
"translations": [
123+
"es",
124+
"us"
125+
],
126+
"graded": true
127+
},
128+
{
129+
"slug": "09-array-of-blog-titles",
130+
"title": "09-array-of-blog-titles",
131+
"done": false,
132+
"path": "exercises/09-array-of-blog-titles",
133+
"translations": [
134+
"es",
135+
"us"
136+
],
137+
"graded": true
138+
},
139+
{
140+
"slug": "10-get_post_tags",
141+
"title": "10-get_post_tags",
142+
"done": false,
143+
"path": "exercises/10-get_post_tags",
144+
"translations": [
145+
"es",
146+
"us"
147+
],
148+
"graded": true
149+
},
150+
{
151+
"slug": "11-get_attachment_by_id",
152+
"title": "11-get_attachment_by_id",
153+
"done": false,
154+
"path": "exercises/11-get_attachment_by_id",
155+
"translations": [
156+
"es",
157+
"us"
158+
],
159+
"graded": true
160+
},
161+
{
162+
"slug": "12-post-request",
163+
"title": "12-post-request",
164+
"done": false,
165+
"path": "exercises/12-post-request",
166+
"translations": [
167+
"es",
168+
"us"
169+
],
170+
"graded": true
171+
},
172+
{
173+
"slug": "13-post-request-body",
174+
"title": "13-post-request-body",
175+
"done": false,
176+
"path": "exercises/13-post-request-body",
177+
"translations": [
178+
"es",
179+
"us"
180+
],
181+
"graded": true
182+
}
183+
]
4184
}

‎exercises/01-what-is-a-request/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import requests
22

3-
url = "https://assets.breatheco.de/apis/fake/sample/404-example.php"
3+
url = "https://assets.breatheco.de/apis/fake/sample/hello.php"
44
response = requests.get(url)
55

66
print("The response status is: "+str(response.status_code))

‎exercises/02-random-status/app.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
11
import requests
22

33
response = requests.get("https://assets.breatheco.de/apis/fake/sample/random-status.php")
4+
5+
if response.status_code == 200:
6+
print("Everything went perfect")
7+
elif response.status_code == 400:
8+
print("Something is wrong on the request params")
9+
elif response.status_code == 404:
10+
print("The URL you asked is not found")
11+
elif response.status_code == 503:
12+
print("Unavailable right now")
13+
else:
14+
print("anything")

‎exercises/03-response-body/app.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
11
import requests
22

3-
url = "https://assets.breatheco.de/apis/fake/sample/random-status.php"
3+
url = "https://assets.breatheco.de/apis/fake/sample/random-status.php"
4+
5+
reponse= requests.get(url)
6+
7+
if reponse.status_code == 200:
8+
print(reponse.text)
9+
else:
10+
print("Something went wrong")

‎exercises/04-response-body-json/app.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
import requests
2-
2+
import json
3+
time = {}
34
response = requests.get("https://assets.breatheco.de/apis/fake/sample/time.php")
4-
print(response.text)
5+
6+
time = response.json()
7+
print(f"Current time: {time['hours']} hrs {time['minutes']} min and {time['seconds']} sec")

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /