Eddie
2 years ago
3 changed files with 59 additions and 6 deletions
@ -0,0 +1,32 @@
|
||||
#from requests.auth import HTTPBasicAuth |
||||
import requests, os |
||||
from dotenv import load_dotenv |
||||
|
||||
load_dotenv() |
||||
# get .env vars |
||||
url = os.getenv('URL') |
||||
key = os.getenv('API_KEY') |
||||
|
||||
header = {"Authorization": "Bearer " + key} |
||||
|
||||
def get_person_all(): |
||||
endpoint = url + 'budget-py-personens' |
||||
r = requests.get(url=endpoint, headers=header) |
||||
data = r.json() |
||||
return data |
||||
|
||||
def get_endpoint(endpoint): |
||||
endpoint = url + endpoint |
||||
r = requests.get(url=endpoint, headers=header) |
||||
data = r.json() |
||||
return data |
||||
|
||||
def post_endpoint(endpoint, data): |
||||
endpoint = url + endpoint |
||||
r = requests.post(url = endpoint, data = data, headers=header) |
||||
|
||||
return r.text |
||||
|
||||
#print(get_person_all()) |
||||
#print(get_endpoint('budget-py-personens')) |
||||
#print(post_endpoint('budget-py-personens', {'Name':'Eddie'})) |
Loading…
Reference in new issue