MingDoan's picture
feat: Add VQA feature
4d5b0bf
raw
history blame
1.43 kB
from requests import get, post, put, delete
from utilities.constants import API_ENDPOINT
def get_data(url, params=None, parse_json=True):
if url.startswith("/"):
url = API_ENDPOINT + url
response = get(url, params=params)
if response.status_code == 200:
if parse_json:
return response.json()
else:
return response.content
else:
return None
def post_data(url, json=None, files=None, data=None, parse_json=True):
if url.startswith("/"):
url = API_ENDPOINT + url
response = post(url, json=json, files=files, data=data)
if response.status_code == 200:
if parse_json:
return response.json()
else:
return response.content
else:
return None
def put_data(url, json=None, parse_json=True):
if url.startswith("/"):
url = API_ENDPOINT + url
response = put(url, json=json)
if response.status_code == 200:
if parse_json:
return response.json()
else:
return response.content
else:
return None
def delete_data(url, json=None, parse_json=True):
if url.startswith("/"):
url = API_ENDPOINT + url
response = delete(url, json=json)
if response.status_code == 200:
if parse_json:
return response.json()
else:
return response.content
else:
return None