mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-12-14 14:25:53 -05:00
Feature/about api (#253)
* fix settings * app info cleanup Co-authored-by: hay-kot <hay-kot@pm.me>
This commit is contained in:
@@ -12,7 +12,7 @@ CWD = Path(__file__).parent
|
||||
BASE_DIR = CWD.parent.parent
|
||||
|
||||
ENV = BASE_DIR.joinpath(".env")
|
||||
PRODUCTION = os.environ.get("ENV")
|
||||
PRODUCTION = os.getenv("ENV", "False").lower() in ["true", "1"]
|
||||
|
||||
|
||||
def determine_data_dir(production: bool) -> Path:
|
||||
@@ -111,7 +111,7 @@ class AppSettings(BaseSettings):
|
||||
SQLITE_FILE: Optional[Union[str, Path]]
|
||||
|
||||
@validator("SQLITE_FILE", pre=True)
|
||||
def identify_sqlite_file(_cls, v: str) -> Optional[str]:
|
||||
def identify_sqlite_file(cls, v: str) -> Optional[str]:
|
||||
return app_dirs.SQLITE_DIR.joinpath(f"mealie_{DB_VERSION}.sqlite")
|
||||
|
||||
DEFAULT_GROUP: str = "Home"
|
||||
@@ -127,3 +127,5 @@ class AppSettings(BaseSettings):
|
||||
|
||||
|
||||
settings = AppSettings()
|
||||
|
||||
print(settings.dict())
|
||||
|
||||
@@ -3,20 +3,15 @@ import json
|
||||
from fastapi import APIRouter, Depends
|
||||
from mealie.core.config import APP_VERSION, LOGGER_FILE, app_dirs, settings
|
||||
from mealie.routes.deps import get_current_user
|
||||
from mealie.schema.debug import AppInfo
|
||||
|
||||
router = APIRouter(prefix="/api/debug", tags=["Debug"])
|
||||
|
||||
|
||||
@router.get("/version")
|
||||
async def get_mealie_version(current_user=Depends(get_current_user)):
|
||||
async def get_mealie_version():
|
||||
""" Returns the current version of mealie"""
|
||||
return {"version": APP_VERSION}
|
||||
|
||||
|
||||
@router.get("/is-demo")
|
||||
async def get_demo_status():
|
||||
print(settings.IS_DEMO)
|
||||
return {"demoStatus": settings.IS_DEMO}
|
||||
return AppInfo(version=APP_VERSION, demo_status=settings.IS_DEMO)
|
||||
|
||||
|
||||
@router.get("/last-recipe-json")
|
||||
|
||||
6
mealie/schema/debug.py
Normal file
6
mealie/schema/debug.py
Normal file
@@ -0,0 +1,6 @@
|
||||
from fastapi_camelcase import CamelModel
|
||||
|
||||
|
||||
class AppInfo(CamelModel):
|
||||
version: str
|
||||
demo_status: bool
|
||||
Reference in New Issue
Block a user