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 131d225

Browse files
proyecto completado
1 parent e6f7bfc commit 131d225

File tree

3 files changed

+41
-5
lines changed

3 files changed

+41
-5
lines changed
Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,26 @@
11
import requests
2+
import numpy as np
3+
import pandas as pd
24

35
def get_attachment_by_id(attachment_id):
46
# Your code here
5-
return None
7+
# lo mismo de siempre:
8+
url = 'https://assets.breatheco.de/apis/fake/sample/weird_portfolio.php'
9+
response = requests.get(url)
10+
if response.status_code == 200:
11+
data = response.json()
12+
posts = data['posts']
13+
for post in posts:
14+
for att in post['attachments']:
15+
if att['id'] == attachment_id:
16+
print("This is the URL of the attachment: ")
17+
return att['url']
18+
19+
20+
else:
21+
return f"Error - no attachments found for the given id."
22+
else:
23+
return f"Something went wrong. Error code: {response.status_code}"
24+
625

7-
print(get_attachment_by_id(137))
26+
print(get_attachment_by_id(104))

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

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

3-
# Your code here
3+
# Your code here
4+
url = 'https://assets.breatheco.de/apis/fake/sample/post.php'
5+
6+
my_obj = {"Nombre": "Leandro",
7+
"Alias": "El Máquina",
8+
"Apellido": "Reguero",
9+
"Edad": 22,
10+
"Sexo": "Cinturón Negro"
11+
}
12+
13+
post_req = requests.post(url, json = my_obj)
14+
print(post_req.text)
15+

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

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

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

0 commit comments

Comments
(0)

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