16 lines
465 B
Python
16 lines
465 B
Python
|
import requests
|
||
|
import logging
|
||
|
|
||
|
class Backend:
|
||
|
def __init__(self, url, apiprefix, apikey):
|
||
|
self.url = url
|
||
|
self.apiprefix = apiprefix
|
||
|
self.apikey = apikey
|
||
|
self.session = requests.Session()
|
||
|
|
||
|
def get(self, endpoint, params=None):
|
||
|
url = f"{self.url}/{self.apiprefix}/{endpoint}"
|
||
|
headers = {"Authorization": f"Token {self.apikey}",
|
||
|
"Accept": "application/json"}
|
||
|
return self.session.get(url, params=params, headers=headers)
|