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 7c8f47f

Browse files
Finished exercise 3.
1 parent 7d3d835 commit 7c8f47f

File tree

1 file changed

+13
-0
lines changed
  • exercises/02-random-status

1 file changed

+13
-0
lines changed

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

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

33
response = requests.get("https://assets.breatheco.de/apis/fake/sample/random-status.php")
4+
5+
response_codes={
6+
'404': 'The URL you asked for is not found',
7+
'503': 'Unavailable right now',
8+
'200': 'Everything went perfect',
9+
'400': 'Something is wrong with the request params'
10+
}
11+
12+
if response.status_code is response_codes.keys():
13+
print(response_codes[response.status_code])
14+
15+
else:
16+
print('Unknown status code')

0 commit comments

Comments
(0)

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