File tree 22 files changed +117
-15
lines changed
22 files changed +117
-15
lines changed Original file line number Diff line number Diff line change
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 ))
Original file line number Diff line number Diff line change
1
+ import requests
2
+
3
+ response = requests .get ("https://assets.breatheco.de/apis/fake/sample/random-status.php" )
Original file line number Diff line number Diff line change
1
+ import requests
2
+
3
+ url = "https://assets.breatheco.de/apis/fake/sample/random-status.php"
Original file line number Diff line number Diff line change
1
+ import requests
2
+
3
+ # your code here
Original file line number Diff line number Diff line change
1
+ import requests
2
+
3
+ # your code here
Original file line number Diff line number Diff line change
1
+ import requests
2
+
3
+ # your code here
Original file line number Diff line number Diff line change
1
+ import requests
2
+
3
+ # your code here
Original file line number Diff line number Diff line change
1
+ import requests
2
+
3
+ def get_titles ():
4
+ # your code here
5
+ return None
6
+
7
+
8
+ print (get_titles ())
Original file line number Diff line number Diff line change
1
+ import requests
2
+
3
+ def get_post_tags (post_id ):
4
+ # your code here
5
+ return None
6
+
7
+
8
+ print (get_post_tags (146 ))
Original file line number Diff line number Diff line change
1
+ import requests
2
+
3
+ def get_attachment_by_id (attachment_id ):
4
+ # your code here
5
+ return None
6
+
7
+ print (get_attachment_by_id (137 ))
Original file line number Diff line number Diff line change 4
4
"editor.minimap.enabled" : false ,
5
5
"workbench.editorAssociations" : {
6
6
"*.md" : " vscode.markdown.preview.editor"
7
- }
7
+ },
8
+ "python.analysis.autoImportCompletions" : true ,
9
+ "python.analysis.typeCheckingMode" : " basic"
8
10
}
Original file line number Diff line number Diff line change 1
1
import requests
2
2
3
- url = "https://assets.breatheco.de/apis/fake/sample/404-example .php"
3
+ url = "https://assets.breatheco.de/apis/fake/sample/hello .php"
4
4
response = requests .get (url )
5
5
6
- print ("The response status is: " + str ( response .status_code ))
6
+ print (f "The response status is: { response .status_code } " ) #El test está mal
Original file line number Diff line number Diff line change 5
5
def test_url (app ):
6
6
with patch ('requests.get' ) as mock_request :
7
7
app ()
8
- url = "https://assets.breatheco.de/apis/fake/sample/hello.php"
8
+ url = "https :// assets .breatheco .de / apis / fake / sample / hello .php
9
+ "
9
10
assert mock_request .call_args .args [0 ] == url
Original file line number Diff line number Diff line change 1
1
import requests
2
2
3
3
response = requests .get ("https://assets.breatheco.de/apis/fake/sample/random-status.php" )
4
+
5
+ def error_code (status ):
6
+ if (status == 200 ):
7
+ return "Everything went perfect\n "
8
+ elif (status == 400 ):
9
+ return "Something is wrong on the request params\n "
10
+ elif (status == 404 ):
11
+ return "The URL you asked is not found\n "
12
+ elif (status == 503 ):
13
+ return "Unavailable right now\n "
14
+
15
+ # TEST FALLAN AUNQUE LAS RESPUETAS SEAN LA CORRECTAS: SyntaxError: invalid decimal literal
16
+
17
+ print (error_code (response .status_code ))
Original file line number Diff line number Diff line change 1
1
import requests
2
2
3
- url = "https://assets.breatheco.de/apis/fake/sample/random-status.php"
3
+ url = "https://assets.breatheco.de/apis/fake/sample/random-status.php"
4
+ response = requests .get (url )
5
+
6
+ if (response .status_code == 200 ):
7
+ print (response .text )
8
+ else :
9
+ print ("Something went wrong." )
Original file line number Diff line number Diff line change 1
1
import requests
2
2
3
- response = requests .get ("https://assets.breatheco.de/apis/fake/sample/time.php" )
4
- print (response .text )
3
+ response = requests .get ("https://assets.breatheco.de/apis/fake/sample/time.php" ).json ()
4
+
5
+ print (f"Current time: { response ['hours' ]} hrs { response ['minutes' ]} and { response ['seconds' ]} sec" )
Original file line number Diff line number Diff line change
1
+ from urllib import request , response
1
2
import requests
2
3
3
- # your code here
4
+ # your code here
5
+ url = "https://assets.breatheco.de/apis/fake/sample/project1.php"
6
+ resp = requests .get (url ).json ()
7
+
8
+ print (resp ['name' ])
Original file line number Diff line number Diff line change 1
1
import requests
2
2
3
- # your code here
3
+ # your code here
4
+ url = "https://assets.breatheco.de/apis/fake/sample/project_list.php"
5
+ resp = requests .get (url ).json ()
6
+
7
+ print (resp [1 ]['name' ])
Original file line number Diff line number Diff line change 1
1
import requests
2
2
3
- # your code here
3
+ # your code here
4
+ url = "https://assets.breatheco.de/apis/fake/sample/project_list.php"
5
+ resp = requests .get (url ).json ()
6
+
7
+ print (resp [- 1 ]['images' ][- 1 ])
Original file line number Diff line number Diff line change 1
1
import requests
2
2
3
- # your code here
3
+ # your code here
4
+ url = "https://assets.breatheco.de/apis/fake/sample/weird_portfolio.php"
5
+ resp = requests .get (url ).json ()
6
+
7
+ print (resp ['posts' ][1 ]['author' ]['name' ])
Original file line number Diff line number Diff line change 1
1
import requests
2
2
3
+
3
4
def get_titles ():
4
- # your code here
5
- return None
5
+ arr_titles = []
6
+ url = "https://assets.breatheco.de/apis/fake/sample/weird_portfolio.php"
7
+ resp = requests .get (url ).json ()
8
+
9
+ for post in resp ['posts' ]:
10
+ arr_titles .append (post ['title' ])\
11
+
12
+ return arr_titles
6
13
7
14
8
15
print (get_titles ())
Original file line number Diff line number Diff line change 1
1
import requests
2
2
3
3
def get_post_tags (post_id ):
4
- # your code here
5
- return None
4
+ post_body = int
5
+ url = "https://assets.breatheco.de/apis/fake/sample/weird_portfolio.php"
6
+ resp = requests .get (url ).json ()
7
+
8
+ for post in resp ['posts' ]:
9
+ if (post ["id" ] == post_id ):
10
+ return post
11
+
12
+
6
13
7
14
8
15
print (get_post_tags (146 ))
You can’t perform that action at this time.
0 commit comments