Skip to content

Instantly share code, notes, and snippets.

View ItMightBlow's full-sized avatar
💭
Not much. Just time passing by

ItMightBlow

💭
Not much. Just time passing by
View GitHub Profile
@stefansundin
stefansundin / requests_api.py
Last active April 11, 2024 16:23
Reusable class for Python requests library.
# http://docs.python-requests.org/en/master/api/
import requests
class RequestsApi:
def __init__(self, base_url, **kwargs):
self.base_url = base_url
self.session = requests.Session()
for arg in kwargs:
if isinstance(kwargs[arg], dict):
kwargs[arg] = self.__deep_merge(getattr(self.session, arg), kwargs[arg])