From f0d51da11de6d9152f9267f72d8870e206a50652 Mon Sep 17 00:00:00 2001 From: code-rgb <62891774+code-rgb@users.noreply.github.com> Date: Mon, 9 Nov 2020 18:20:12 +0530 Subject: [PATCH] Added aiohttp Helper --- userge/utils/helper/__init__.py | 1 + userge/utils/helper/aiohttp_helper.py | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 userge/utils/helper/__init__.py create mode 100644 userge/utils/helper/aiohttp_helper.py diff --git a/userge/utils/helper/__init__.py b/userge/utils/helper/__init__.py new file mode 100644 index 000000000..055e9e08a --- /dev/null +++ b/userge/utils/helper/__init__.py @@ -0,0 +1 @@ +from .aiohttp_helper import AioHttp \ No newline at end of file diff --git a/userge/utils/helper/aiohttp_helper.py b/userge/utils/helper/aiohttp_helper.py new file mode 100644 index 000000000..4501de9e3 --- /dev/null +++ b/userge/utils/helper/aiohttp_helper.py @@ -0,0 +1,21 @@ +import aiohttp + + +class AioHttp: + @staticmethod + async def get_json(link): + async with aiohttp.ClientSession() as session: + async with session.get(link) as resp: + return await resp.json() + + @staticmethod + async def get_text(link): + async with aiohttp.ClientSession() as session: + async with session.get(link) as resp: + return await resp.text() + + @staticmethod + async def get_raw(link): + async with aiohttp.ClientSession() as session: + async with session.get(link) as resp: + return await resp.read() \ No newline at end of file