mirror of
https://github.com/clearml/clearml-server
synced 2025-02-07 13:33:42 +00:00
22 lines
661 B
Python
22 lines
661 B
Python
import requests
|
|
from furl import furl
|
|
from requests.auth import HTTPBasicAuth
|
|
|
|
from config import config
|
|
|
|
|
|
class SimpleSession:
|
|
def __init__(self):
|
|
self.host = config["hosts.api_server"]
|
|
if not self.host.startswith("http"):
|
|
self.host = f"http://{self.host}"
|
|
|
|
self.key = config.get("secure.credentials.webserver.user_key")
|
|
self.secret = config.get("secure.credentials.webserver.user_secret")
|
|
|
|
self.auth = HTTPBasicAuth(self.key, self.secret)
|
|
|
|
def send_request(self, endpoint, json=None):
|
|
url = furl(self.host).set(path=endpoint)
|
|
return requests.get(str(url), json=json, auth=self.auth)
|