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 f60fda7

Browse files
completing exercises
1 parent 8b6eb7b commit f60fda7

File tree

4 files changed

+31
-1
lines changed
  • .learn/resets
  • exercises

4 files changed

+31
-1
lines changed
Lines changed: 6 additions & 0 deletions
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))

‎.learn/resets/02-random-status/app.py

Lines changed: 3 additions & 0 deletions
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")

‎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: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
11
import requests
22

3+
import requests
4+
35
response = requests.get("https://assets.breatheco.de/apis/fake/sample/random-status.php")
6+
7+
status_code = str(response.status_code)
8+
9+
print("The response status is: "+str(response.status_code))
10+
11+
if status_code == '404':
12+
print('The URL you asked is not found')
13+
14+
elif status_code == '503':
15+
print('Unavailable right now')
16+
17+
elif status_code == '200':
18+
print('Everything went perfect')
19+
20+
elif status_code == '400':
21+
print('Something is wrong on the request params')
22+
23+
else:
24+
print('Anything Else')

0 commit comments

Comments
(0)

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