forked from AWSCC-PUP-DWD/AWSCC-CodeQuest-Backend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
https.py
32 lines (23 loc) · 705 Bytes
/
https.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# Challenge time Day 17
import requests
# base url
base_url = "https://jsonplaceholder.typicode.com/"
# Resource Path
resource_path = "/users"
# Parameters
parameters = {"status": "active", "sort": "desc"}
# Construct the complete endpoint URL
endpoint_url = base_url + resource_path
if parameters:
endpoint_url += "?" + "&".join([f"{key}={value}" for key, value in parameters.items()])
# Sending a GET request to the constructed endpoint URL
response = requests.get("https://jsonplaceholder.typicode.com/")
if response == 200:
print("Request Successful")
else:
print("Request Failed")
# Handle the Response as needed
print("API Response:", response.text)
"""
Needed More Reading.
"""