Initial commit

This commit is contained in:
allegroai
2019-06-11 00:24:35 +03:00
parent 6eea80c4a2
commit a6344bad57
138 changed files with 15951 additions and 0 deletions

View File

@@ -0,0 +1,6 @@
from factory import Factory
from .simple import SimpleSession
class SessionFactory(Factory):
default_cls = SimpleSession

View 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)