File size: 962 Bytes
4e99679 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# 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
|