@@ -60,6 +60,53 @@ def get_request(cls):
6060 except Exception as e :
6161 print (e )
6262
63+ @classmethod
64+ def delete_endpoint_request (cls ):
65+ request_url = cls .default_url
66+ request_headers = cls .default_headers
67+ input_url = input ('Enter URL: ' )
68+ input_headers = input ('Enter Headers: ' )
69+ if input_url != '' :
70+ request_url = input_url
71+ if input_headers != '' :
72+ try :
73+ request_headers = json .loads (input_headers )
74+ except Exception :
75+ print ("Failed to parse Input Headers" )
76+ # Check whether the request_url has an endpoint or not
77+ has_endpoint = cls .__check_endpoint (request_url )
78+
79+ # Check if http:// or https:// is present in request_url
80+ has_protocol = cls .__check_protocol (request_url )
81+
82+ if not (has_protocol ):
83+ request_url = "https://" + request_url
84+
85+ # Ask the user for endpoint if not present in request_url
86+ if not (has_endpoint ):
87+ if (request_url [- 1 ] == '/' ):
88+ endpoint = input ("Input endpoint " +
89+ "(Without the starting slash): " )
90+ else :
91+ endpoint = input ("Input endpoint (With the starting slash): " )
92+ request_url += endpoint
93+
94+ print ("Trying ...\u26A1 " )
95+ try :
96+ response = requests .delete (request_url , headers = request_headers )
97+ print (f"Reponse Status Code: { response .status_code } " )
98+ response_data = json .loads (response .content )
99+ parsed_json = json .dumps (response_data , indent = 4 )
100+ output_json = highlight (parsed_json , lexers .JsonLexer (),
101+ formatters .TerminalFormatter ())
102+ print (output_json )
103+
104+ except requests .exceptions .InvalidSchema :
105+ print ("Check whether the URL is valid or check if " +
106+ "the localhost server is active or not" )
107+ except Exception as e :
108+ print (e )
109+
63110 @classmethod
64111 def __check_endpoint (cls , request_url ):
65112 if (request_url == cls .default_url ):
0 commit comments