Skip to content

Instantly share code, notes, and snippets.

@KenoLeon
Last active May 10, 2022 00:53
Show Gist options
  • Select an option

  • Save KenoLeon/c237525a81d7c8520cd8e426a9116612 to your computer and use it in GitHub Desktop.

Select an option

Save KenoLeon/c237525a81d7c8520cd8e426a9116612 to your computer and use it in GitHub Desktop.
example of using requests in Python
import requests
from requests.structures import CaseInsensitiveDict
# ENDPOINT:
url = "http://colormind.io/api/"
# Request Format
headers = CaseInsensitiveDict()
headers["Content-Type"] = "application/json"
data = '{"model":"default"}'
# Request:
resp = requests.post(url, headers=headers, data=data)
if resp.status_code == 200:
print(resp.json())
else:
print(resp.status_code)
# >>
# {'result': [[252, 236, 177],
# [225, 195, 67],
# [248, 65, 32],
# [145, 43, 75],
# [68, 43, 87]]}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment