We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent ab2e256 commit e6a1521Copy full SHA for e6a1521
1 file changed
src/arguments/api_test.py
@@ -0,0 +1,23 @@
1
+import requests, json
2
+
3
+class Api_Testing():
4
+ default_url = "127.0.0.1:8000"
5
6
+ @classmethod
7
+ def get_request(self):
8
+ request_url = Api_Testing.default_url
9
+ input_url = input('Enter URL: ')
10
+ if input_url != '':
11
+ request_url = input_url
12
13
+ try:
14
+ response = requests.get(request_url)
15
+ print(f"Reponse Status Code: {response.status_code}")
16
+ print("Response data stored in response_data.json")
17
+ parsed = json.loads(response.content)
18
+ with open('response_data.json', 'w') as jsonFile:
19
+ json.dump(parsed, jsonFile, indent=4)
20
+ except requests.exceptions.InvalidSchema:
21
+ print("Check whether the URL is valid or check if the localhost server is active or not")
22
+ except Exception as e:
23
+ print(e)
0 commit comments