ISM2023w / request_api.py
debayan's picture
Upload folder using huggingface_hub
4e99679
raw
history blame
962 Bytes
# Generic code to make api requests using python requests library: frame
import requests
from urllib.parse import urljoin, urlencode, urlparse, urlunparse
# Define the base URL
BASE_URL = 'https://6146-134-28-45-21.ngrok-free.app/'
#BASE_URL = 'http://127.0.0.1:5000/'
def make_get_request(endpoint,params):
# Make a GET request to the endpoint
response = requests.get(
url = f'{BASE_URL}{endpoint}',
params=params,
verify=False
)
# Check if the response is successful
return response
# Make a POST request to the endpoint
def make_post_request(endpoint,params,data=None):
if data is None:
return
# Make a POST request to the endpoint
response = requests.post(
url=BASE_URL + endpoint,
params=params,
data=data,
verify=False
)
# Check if the response is successful
# Return the error
return response