mirror of
https://github.com/clearml/clearml-server
synced 2025-06-26 23:15:47 +00:00
Initial commit
This commit is contained in:
6
webserver/session/__init__.py
Normal file
6
webserver/session/__init__.py
Normal file
@@ -0,0 +1,6 @@
|
||||
from factory import Factory
|
||||
from .simple import SimpleSession
|
||||
|
||||
|
||||
class SessionFactory(Factory):
|
||||
default_cls = SimpleSession
|
||||
21
webserver/session/simple.py
Normal file
21
webserver/session/simple.py
Normal file
@@ -0,0 +1,21 @@
|
||||
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)
|
||||
Reference in New Issue
Block a user