proiect finalizat

This commit is contained in:
andrei-mihnea-cerbu
2024-01-13 12:59:19 +02:00
parent 54542da299
commit 67b7a241d7
53 changed files with 321 additions and 19 deletions
+12 -2
View File
@@ -3,16 +3,26 @@ import requests
class _HttpRequestHandler:
"""
A Builder for HTTP Request class
Attributes:
url (str): URL at which the request is made
headers (dict):
body (dict):
params (dict): Query params
method (str): HTTP method (GET, POST, ...)
"""
def __init__(self, url, method="GET", params=None, headers=None, body=None):
self.url = url
self.method = method
self.headers = headers
print(body)
self.body = json.dumps(body)
self.params = params
def make_request(self):
print(self.body)
"""Make HTTP request and returns the answer"""
response = requests.request(method=self.method, url=self.url,
params=self.params, data=self.body, headers=self.headers)
return response