mirror of
https://github.com/Redume/Shirino.git
synced 2025-03-14 18:37:51 +03:00
refactor: Rewrote the creation of graphs on aiohttp
This commit is contained in:
parent
f122614b9f
commit
d8d6635987
1 changed files with 19 additions and 0 deletions
19
functions/create_chart.py
Normal file
19
functions/create_chart.py
Normal file
|
@ -0,0 +1,19 @@
|
|||
import yaml
|
||||
import aiohttp
|
||||
|
||||
from http import HTTPStatus
|
||||
|
||||
config = yaml.safe_load(open('config.yaml'))
|
||||
|
||||
async def create_chart(from_currency: str, conv_currency: str) -> (dict, None):
|
||||
async with aiohttp.ClientSession(timeout=aiohttp.ClientTimeout(total=3)) as session:
|
||||
async with session.get(f'{config["kekkai_instance"]}/api/getChart/week/', params={
|
||||
'from_currency': from_currency,
|
||||
'conv_currency': conv_currency
|
||||
}) as res:
|
||||
if not HTTPStatus(res.status).is_success:
|
||||
return None
|
||||
|
||||
data = await res.json()
|
||||
|
||||
return data.get('message', None)
|
Loading…
Add table
Add a link
Reference in a new issue