Intitial release
This commit is contained in:
parent
299038fbc7
commit
fa8caa5116
21 changed files with 1234 additions and 0 deletions
19
utils/common_utils.py
Normal file
19
utils/common_utils.py
Normal file
|
@ -0,0 +1,19 @@
|
|||
from httpx import AsyncClient
|
||||
|
||||
class HttpxHelperClient:
|
||||
def __init__(self):
|
||||
self.client = AsyncClient(timeout=60.0)
|
||||
|
||||
async def get(self, url, headers=None):
|
||||
response = await self.client.get(url, headers=headers)
|
||||
return response
|
||||
|
||||
async def post(self, url, data=None, json=None, headers=None):
|
||||
response = await self.client.post(url, data=data, json=json, headers=headers)
|
||||
return response
|
||||
|
||||
async def download(self, url, file_path, headers=None):
|
||||
response = await self.client.get(url, headers=headers)
|
||||
with open(file_path, 'wb') as f:
|
||||
f.write(response.content)
|
||||
return file_path
|
Loading…
Add table
Add a link
Reference in a new issue