From e9d6ad3811c8975ae1c40f26353389ed9dac65a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn-Michael=20Miehe?= <40151420+ldericher@users.noreply.github.com> Date: Sun, 20 Mar 2022 02:25:42 +0000 Subject: [PATCH] data_dir setting --- api/kiwi_vpn_api/config.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/api/kiwi_vpn_api/config.py b/api/kiwi_vpn_api/config.py index 3d48d76..31c3add 100644 --- a/api/kiwi_vpn_api/config.py +++ b/api/kiwi_vpn_api/config.py @@ -4,7 +4,8 @@ import functools import json from datetime import datetime, timedelta from enum import Enum -from secrets import token_hex +from pathlib import Path +from secrets import token_urlsafe from jose import JWTError, jwt from jose.constants import ALGORITHMS @@ -16,7 +17,8 @@ from sqlalchemy.engine import Engine class Settings(BaseSettings): production_mode: bool = False - config_file: str = "tmp/config.json" + data_dir: Path = Path("./tmp") + config_file: Path = Path("tmp/config.json") openapi_url: str = "/openapi.json" docs_url: str | None = "/docs" redoc_url: str | None = "/redoc" @@ -37,7 +39,7 @@ class DBConfig(BaseModel): user: str | None = None password: str | None = None host: str | None = None - database: str | None = "./tmp/vpn.db" + database: str | None = Settings.get().data_dir.joinpath("vpn.db") mysql_driver: str = "pymysql" mysql_args: list[str] = ["charset=utf8mb4"]