mirror of
https://github.com/Redume/Shirino.git
synced 2025-07-04 03:00:55 +01:00
chore: Transmitted the receipt of the graph
This commit is contained in:
parent
159036957a
commit
81a57e4b9e
1 changed files with 18 additions and 14 deletions
|
@ -1,4 +1,5 @@
|
||||||
from http import HTTPStatus
|
from http import HTTPStatus
|
||||||
|
from urllib.parse import urlencode
|
||||||
|
|
||||||
import yaml
|
import yaml
|
||||||
import aiohttp
|
import aiohttp
|
||||||
|
@ -8,19 +9,22 @@ config = yaml.safe_load(open('../config.yaml', 'r', encoding='utf-8'))
|
||||||
async def create_chart(
|
async def create_chart(
|
||||||
from_currency: str,
|
from_currency: str,
|
||||||
conv_currency: str,
|
conv_currency: str,
|
||||||
period: str) -> (dict, None):
|
period: str,
|
||||||
async with aiohttp.ClientSession(
|
backend: str) -> (str, None):
|
||||||
timeout=aiohttp.ClientTimeout(total=3)
|
|
||||||
) as session:
|
|
||||||
async with session.get(
|
|
||||||
f'{config["kekkai_instance"]}/api/getChart/{period}/',
|
|
||||||
params = {
|
params = {
|
||||||
'from_currency': from_currency,
|
'from_currency': from_currency,
|
||||||
'conv_currency': conv_currency
|
'conv_currency': conv_currency,
|
||||||
}) as res:
|
'period': period,
|
||||||
|
'backend': backend
|
||||||
|
}
|
||||||
|
|
||||||
|
base_url = f'{config["kekkai_instance"]}/api/getChart/'
|
||||||
|
query_string = urlencode(params)
|
||||||
|
full_url = f'{base_url}?{query_string}'
|
||||||
|
|
||||||
|
async with aiohttp.ClientSession(timeout=aiohttp.ClientTimeout(total=3)) as session:
|
||||||
|
async with session.get(full_url) as res:
|
||||||
if not HTTPStatus(res.status).is_success:
|
if not HTTPStatus(res.status).is_success:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
data = await res.json()
|
return full_url
|
||||||
|
|
||||||
return data.get('detail', None)
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue