mirror of
https://github.com/Andre-Bzk/Rezept0r.git
synced 2026-11-15 09:33:05 +01:00
fix: speicherort history.db und images Ordner
- Bilder: data/images - SQLite: data/history.db
This commit is contained in:
@@ -0,0 +1,10 @@
|
|||||||
|
.env
|
||||||
|
.venv
|
||||||
|
__pycache__
|
||||||
|
*.pyc
|
||||||
|
data
|
||||||
|
tmp
|
||||||
|
.git
|
||||||
|
.gitignore
|
||||||
|
.vscode
|
||||||
|
.claude
|
||||||
+1
-2
@@ -8,7 +8,6 @@ APP_PORT=8000
|
|||||||
# Für andere Deployments anpassen, z.B. /volume1/docker/rezept0r/tmp
|
# Für andere Deployments anpassen, z.B. /volume1/docker/rezept0r/tmp
|
||||||
REZEPTOR_TMP_DIR=./tmp
|
REZEPTOR_TMP_DIR=./tmp
|
||||||
REZEPTOR_DATA_DIR=./data
|
REZEPTOR_DATA_DIR=./data
|
||||||
TMP_DIR=/app/tmp
|
TMP_DIR=tmp
|
||||||
# FFMPEG_LOCATION nur unter Windows notwendig
|
# FFMPEG_LOCATION nur unter Windows notwendig
|
||||||
FFMPEG_LOCATION=C:\Users\andre\AppData\Local\Microsoft\WinGet\Packages\Gyan.FFmpeg_Microsoft.Winget.Source_8wekyb3d8bbwe\ffmpeg-8.0.1-full_build\bin
|
FFMPEG_LOCATION=C:\Users\andre\AppData\Local\Microsoft\WinGet\Packages\Gyan.FFmpeg_Microsoft.Winget.Source_8wekyb3d8bbwe\ffmpeg-8.0.1-full_build\bin
|
||||||
IMAGES_DIR=./data/images
|
|
||||||
|
|||||||
@@ -55,9 +55,13 @@ TANDOOR_API_TOKEN=tda_...
|
|||||||
| `USDA_API_KEY` | Nein | USDA FoodData Central Key (Standard: `DEMO_KEY`) |
|
| `USDA_API_KEY` | Nein | USDA FoodData Central Key (Standard: `DEMO_KEY`) |
|
||||||
| `TANDOOR_BASE_URL` | Nein | URL der Tandoor-Instanz |
|
| `TANDOOR_BASE_URL` | Nein | URL der Tandoor-Instanz |
|
||||||
| `TANDOOR_API_TOKEN` | Nein | Tandoor Bearer-Token |
|
| `TANDOOR_API_TOKEN` | Nein | Tandoor Bearer-Token |
|
||||||
| `TMP_DIR` | Nein | Verzeichnis fuer temporaere Audio-Dateien (Standard: `/app/tmp`) |
|
| `TMP_DIR` | Nein | Verzeichnis fuer temporaere Audio-Dateien (Standard: `tmp`, also `<Projekt>/tmp` bzw. im Container `/app/tmp`) |
|
||||||
| `FFMPEG_LOCATION` | Nein | Pfad zu ffmpeg (nur fuer lokale Windows-Entwicklung) |
|
| `FFMPEG_LOCATION` | Nein | Pfad zu ffmpeg (nur fuer lokale Windows-Entwicklung) |
|
||||||
|
|
||||||
|
Bilder und Verlauf-DB liegen immer fest unter `<Projekt>/data` bzw. im Container unter `/app/data`:
|
||||||
|
- Bilder: `data/images`
|
||||||
|
- SQLite: `data/history.db`
|
||||||
|
|
||||||
### 3. Starten
|
### 3. Starten
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
|||||||
+36
-4
@@ -1,9 +1,15 @@
|
|||||||
from pydantic_settings import BaseSettings, SettingsConfigDict
|
|
||||||
from functools import lru_cache
|
from functools import lru_cache
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
from pydantic import computed_field, field_validator
|
||||||
|
from pydantic_settings import BaseSettings, SettingsConfigDict
|
||||||
|
|
||||||
|
|
||||||
|
BASE_DIR = Path(__file__).resolve().parent.parent
|
||||||
|
|
||||||
|
|
||||||
class Settings(BaseSettings):
|
class Settings(BaseSettings):
|
||||||
model_config = SettingsConfigDict(env_file=".env", env_file_encoding="utf-8")
|
model_config = SettingsConfigDict(env_file=".env", env_file_encoding="utf-8", extra="ignore")
|
||||||
|
|
||||||
openai_api_key: str = ""
|
openai_api_key: str = ""
|
||||||
usda_api_key: str = "DEMO_KEY"
|
usda_api_key: str = "DEMO_KEY"
|
||||||
@@ -11,10 +17,36 @@ class Settings(BaseSettings):
|
|||||||
tandoor_api_token: str = ""
|
tandoor_api_token: str = ""
|
||||||
app_host: str = "0.0.0.0"
|
app_host: str = "0.0.0.0"
|
||||||
app_port: int = 8000
|
app_port: int = 8000
|
||||||
tmp_dir: str = "/app/tmp"
|
tmp_dir: str = "tmp"
|
||||||
images_dir: str = "/app/data/images"
|
|
||||||
ffmpeg_location: str = "" # Optional: full path to ffmpeg binary dir (for Windows local dev)
|
ffmpeg_location: str = "" # Optional: full path to ffmpeg binary dir (for Windows local dev)
|
||||||
|
|
||||||
|
@field_validator("tmp_dir", "ffmpeg_location", mode="before")
|
||||||
|
@classmethod
|
||||||
|
def _resolve_project_relative_paths(cls, value: str) -> str:
|
||||||
|
if not value:
|
||||||
|
return value
|
||||||
|
if value.startswith(("/", "\\")):
|
||||||
|
return value
|
||||||
|
path = Path(value).expanduser()
|
||||||
|
if path.is_absolute():
|
||||||
|
return str(path)
|
||||||
|
return str((BASE_DIR / path).resolve())
|
||||||
|
|
||||||
|
@computed_field
|
||||||
|
@property
|
||||||
|
def data_dir(self) -> str:
|
||||||
|
return str(BASE_DIR / "data")
|
||||||
|
|
||||||
|
@computed_field
|
||||||
|
@property
|
||||||
|
def images_dir(self) -> str:
|
||||||
|
return str(Path(self.data_dir) / "images")
|
||||||
|
|
||||||
|
@computed_field
|
||||||
|
@property
|
||||||
|
def history_db_path(self) -> str:
|
||||||
|
return str(Path(self.data_dir) / "history.db")
|
||||||
|
|
||||||
|
|
||||||
@lru_cache
|
@lru_cache
|
||||||
def get_settings() -> Settings:
|
def get_settings() -> Settings:
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ from app.config import get_settings
|
|||||||
|
|
||||||
def _db_path() -> Path:
|
def _db_path() -> Path:
|
||||||
settings = get_settings()
|
settings = get_settings()
|
||||||
return Path(settings.images_dir).parent / "history.db"
|
return Path(settings.history_db_path)
|
||||||
|
|
||||||
|
|
||||||
def init_db() -> None:
|
def init_db() -> None:
|
||||||
|
|||||||
Reference in New Issue
Block a user