[Python] requests




Get

import requests
import json

url = '[URL]'
    
response = requests.get(url, verify=False)

response_data = json.loads(response.text)

if(response.status_code==200):
    return response_data
else:
    return "Error Code:" + response.status_code

Post

import requests
import json

url = '[URL]'

headers = {
    "Content-type" : "application/json"
}

data = {
    "key" : "value"
}

response = requests.post(url, headers=headers, data=json.dumps(data), verify=False)

response_data = json.loads(response.text)

if(response.status_code==200):
    return response_data
else:
    return "Error Code:" + response.status_code


Leave a Comment