This commit is contained in:
BarsTiger
2023-10-07 22:51:05 +03:00
parent 2f14f4d1ee
commit 9d45084d98
33 changed files with 2205 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
import aiohttp
from shazamio.exceptions import BadMethod
from shazamio.utils import validate_json
class HTTPClient:
@staticmethod
async def request(method: str, url: str, *args, **kwargs) -> dict:
async with aiohttp.ClientSession() as session:
if method.upper() == "GET":
async with session.get(url, **kwargs) as resp:
return await validate_json(resp, *args)
elif method.upper() == "POST":
async with session.post(url, **kwargs) as resp:
return await validate_json(resp, *args)
else:
raise BadMethod("Accept only GET/POST")