advent22/api/advent22_api/config.py

22 lines
398 B
Python
Raw Normal View History

2022-11-04 18:49:31 +00:00
import tomli
from pydantic import BaseModel
from .dav_common import dav_get_textfile_content
from .settings import SETTINGS
2022-11-15 22:17:32 +00:00
class User(BaseModel):
name: str
password: str
2022-11-04 18:49:31 +00:00
class Config(BaseModel):
2022-11-15 22:17:32 +00:00
admin: User
2022-11-04 18:49:31 +00:00
solution: str
async def get_config() -> Config:
txt = await dav_get_textfile_content(path=SETTINGS.config_filename)
return Config.parse_obj(tomli.loads(txt))