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 32c1a86

Browse files
first commit
1 parent f4e1fa0 commit 32c1a86

File tree

6 files changed

+40
-8
lines changed

6 files changed

+40
-8
lines changed

‎exercises/08-blog-post-author/app.py

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

3+
response = requests.get("https://assets.breatheco.de/apis/fake/sample/weird_portfolio.php")
4+
5+
resp_json=response.json()
6+
7+
print(resp_json['posts'][0]['author']['name'])
38
# Your code here

‎exercises/09-list-of-blog-titles/app.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
import requests
22

3+
4+
35
def get_titles():
4-
# Your code here
5-
return None
6+
titles = []
7+
response = requests.get("https://assets.breatheco.de/apis/fake/sample/weird_portfolio.php")
8+
resp_json=response.json()
9+
for post in resp_json['posts']:
10+
titles.append(post['title'])
11+
12+
return titles
613

714

815
print(get_titles())

‎exercises/10-get-post-tags/app.py

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

33
def get_post_tags(post_id):
4-
# Your code here
5-
return None
4+
response = requests.get("https://assets.breatheco.de/apis/fake/sample/weird_portfolio.php")
5+
resp_json=response.json()
6+
for post in resp_json['posts']:
7+
if post['id'] == post_id:
8+
return post['tags']
69

710

811
print(get_post_tags(146))
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import requests
22

33
def get_attachment_by_id(attachment_id):
4-
# Your code here
5-
return None
4+
response = requests.get("https://assets.breatheco.de/apis/fake/sample/weird_portfolio.php")
5+
resp_json=response.json()
6+
for post in resp_json['posts']:
7+
for attch in post['attachments']:
8+
if attch['id'] == attachment_id:
9+
return attch['title']
610

711
print(get_attachment_by_id(137))

‎exercises/12-post-request/app.py

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

3-
# Your code here
3+
response=requests.post("https://assets.breatheco.de/apis/fake/sample/post.php")
4+
resp_json=response.json()
5+
6+
print(resp_json)

‎exercises/13-post-request-body/app.py

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

3-
response = requests.post("https://assets.breatheco.de/apis/fake/sample/save-project-json.php")
3+
body = {
4+
"id": 2323,
5+
"title": "Very big project"
6+
}
7+
8+
response = requests.post(
9+
"https://assets.breatheco.de/apis/fake/sample/save-project-json.php",
10+
json=body,
11+
# headers={'Content-Type': 'application/json'}
12+
)
13+
414
print(response.text)

0 commit comments

Comments
(0)

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