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 a234fd3

Browse files
exercise_08
1 parent f90a785 commit a234fd3

File tree

15 files changed

+76
-12
lines changed

15 files changed

+76
-12
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import requests
2+
3+
url = "https://assets.breatheco.de/apis/fake/sample/404-example.php"
4+
# url = "https://assets.breatheco.de/apis/fake/sample/hello.php"
5+
response = requests.get(url)
6+
7+
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")

‎.learn/resets/03-response-body/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+
url = "https://assets.breatheco.de/apis/fake/sample/random-status.php"
Lines changed: 4 additions & 0 deletions
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)

‎.learn/resets/05-project-name/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+
# Your code here

‎.learn/resets/06-project-list/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+
# Your code here
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import requests
2+
3+
# Your code here
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import requests
2+
3+
# Your code here

‎exercises/01-creating-a-request/app.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import requests
22

3-
url = "https://assets.breatheco.de/apis/fake/sample/404-example.php"
4-
# url = "https://assets.breatheco.de/apis/fake/sample/hello.php"
3+
url = "https://assets.breatheco.de/apis/fake/sample/hello.php"
54
response = requests.get(url)
6-
7-
print("The response status is: "+str(response.status_code))
5+
print(response.status_code)

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
11
import requests
2-
3-
response = requests.get("https://assets.breatheco.de/apis/fake/sample/random-status.php")
2+
url = 'https://assets.breatheco.de/apis/fake/sample/random-status.php'
3+
response = requests.get(url)
4+
status = response.status_code
5+
if status == 404:
6+
print('The URL you asked for is not found')
7+
elif status == 503:
8+
print('Unavailable right now')
9+
elif status == 200:
10+
print('Everything went perfect')
11+
elif status == 400:
12+
print('Something is wrong with the request params')
13+
else:
14+
print('Unknown status code')

0 commit comments

Comments
(0)

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