15 lines
386 B
Python
15 lines
386 B
Python
from fastapi import APIRouter
|
|
from functools import lru_cache
|
|
import json
|
|
import asyncio
|
|
|
|
router = APIRouter(prefix='/api/v1', tags=['tariffs'])
|
|
|
|
@lru_cache(maxsize=1)
|
|
def get_tariffs_sync():
|
|
with open('data/tariffs.json', 'r', encoding='utf-8') as f:
|
|
return json.load(f)
|
|
|
|
@router.get('/tariffs')
|
|
async def get_tariffs():
|
|
return await asyncio.to_thread(get_tariffs_sync) |