File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed
Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change 33
44class ApiTesting ():
55 default_url = "https://127.0.0.1:8000"
6-
6+ default_headers = {}
77 # Make GET request
88 @classmethod
99 def get_request (cls ):
1010 request_url = cls .default_url
11+ request_headers = cls .default_headers
1112 input_url = input ('Enter URL: ' )
13+ input_headers = input ('Enter Headers: ' )
1214 if input_url != '' :
1315 request_url = input_url
14-
16+ if input_headers != '' :
17+ try :
18+ request_headers = json .loads (input_headers )
19+ except Exception :
20+ print ("Failed to parse Input Headers" )
1521 # Check whether the request_url has an endpoint or not
1622 has_endpoint = cls .__check_endpoint (request_url )
1723
@@ -33,7 +39,7 @@ def get_request(cls):
3339
3440 # Make GET request and store the response in response_data.json
3541 try :
36- response = requests .get (request_url )
42+ response = requests .get (request_url , headers = request_headers )
3743 print (f"Reponse Status Code: { response .status_code } " )
3844 response_data = json .loads (response .content )
3945 parsed_json = json .dumps (response_data , indent = 4 )
You can’t perform that action at this time.
0 commit comments