Skip to content
This repository has been archived by the owner on May 15, 2021. It is now read-only.

Commit

Permalink
Added aiohttp Helper
Browse files Browse the repository at this point in the history
  • Loading branch information
code-rgb committed Nov 9, 2020
1 parent a3d1d3d commit f0d51da
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions userge/utils/helper/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .aiohttp_helper import AioHttp
21 changes: 21 additions & 0 deletions userge/utils/helper/aiohttp_helper.py
Original file line number Diff line number Diff line change
@@ -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()

1 comment on commit f0d51da

@vercel
Copy link

@vercel vercel bot commented on f0d51da Nov 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.