versione prima dle menu della clincia
This commit is contained in:
31
backend/app/config.py
Normal file
31
backend/app/config.py
Normal file
@@ -0,0 +1,31 @@
|
||||
from pathlib import Path
|
||||
import os
|
||||
|
||||
from dotenv import load_dotenv
|
||||
|
||||
|
||||
BASE_DIR = Path(__file__).resolve().parent.parent
|
||||
PROJECT_ROOT = BASE_DIR.parent
|
||||
ENV_FILE = PROJECT_ROOT / ".env"
|
||||
|
||||
load_dotenv(ENV_FILE)
|
||||
|
||||
|
||||
class Settings:
|
||||
def __init__(self) -> None:
|
||||
self.app_name = os.getenv("APP_NAME", "Clinica Veterinaria Formiginese API")
|
||||
self.app_env = os.getenv("APP_ENV", "development")
|
||||
self.app_host = os.getenv("APP_HOST", "127.0.0.1")
|
||||
self.app_port = int(os.getenv("APP_PORT", "8000"))
|
||||
default_sqlite_path = (PROJECT_ROOT / "data" / "clinica.db").resolve()
|
||||
self.database_url = os.getenv("DATABASE_URL", f"sqlite:///{default_sqlite_path.as_posix()}")
|
||||
|
||||
@property
|
||||
def sqlite_file_path(self) -> str | None:
|
||||
sqlite_prefix = "sqlite:///"
|
||||
if self.database_url.startswith(sqlite_prefix):
|
||||
return self.database_url.removeprefix(sqlite_prefix)
|
||||
return None
|
||||
|
||||
|
||||
settings = Settings()
|
||||
Reference in New Issue
Block a user