22 lines
646 B
Python
22 lines
646 B
Python
"""Wrap backend requests for usage in commands."""
|
|
import logging
|
|
from urllib.parse import urljoin
|
|
|
|
import requests
|
|
|
|
import hitomi.config as config
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
class DrBotzoBackend(object):
|
|
"""Basic HTTP requests API, wrapped with some authentication and config stuff."""
|
|
|
|
def post(self, url, **kwargs):
|
|
"""Wrap requests.post with authentication and hostname settings."""
|
|
return requests.post(urljoin(config.DR_BOTZO_BACKEND_HOST, url),
|
|
auth=(config.DR_BOTZO_BACKEND_USER, config.DR_BOTZO_BACKEND_PASS), **kwargs)
|
|
|
|
|
|
dr_botzo = DrBotzoBackend()
|