- PUID/PGID Unterstützung für Unraid/Docker hinzugefügt - Entrypoint-Skript für Benutzer-Wechsel - ZUGFeRD-Dateien werden jetzt direkt in Zielordner verschoben (kein extra zugferd/ Unterordner) - Dokumentation aktualisiert Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
77 lines
1.9 KiB
Python
Executable file
77 lines
1.9 KiB
Python
Executable file
"""
|
|
Dateiverwaltung - Modulares Dokumenten-Management-System
|
|
Hauptanwendung mit FastAPI
|
|
"""
|
|
from contextlib import asynccontextmanager
|
|
from fastapi import FastAPI
|
|
from fastapi.staticfiles import StaticFiles
|
|
from fastapi.templating import Jinja2Templates
|
|
from fastapi.responses import HTMLResponse
|
|
from fastapi import Request
|
|
from pathlib import Path
|
|
import logging
|
|
|
|
from .models import init_db
|
|
from .routes.api import router as api_router
|
|
from .config import BASE_DIR
|
|
from .services.scheduler_service import init_scheduler, shutdown_scheduler
|
|
|
|
# Logging konfigurieren
|
|
logging.basicConfig(
|
|
level=logging.INFO,
|
|
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s"
|
|
)
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
@asynccontextmanager
|
|
async def lifespan(app: FastAPI):
|
|
"""Lifecycle-Management für die App"""
|
|
# Startup
|
|
print("=== Dateiverwaltung startet ===", flush=True)
|
|
init_db()
|
|
print("Datenbank initialisiert", flush=True)
|
|
init_scheduler()
|
|
print("Scheduler initialisiert", flush=True)
|
|
|
|
yield
|
|
|
|
# Shutdown
|
|
shutdown_scheduler()
|
|
print("Scheduler beendet", flush=True)
|
|
|
|
|
|
# App erstellen
|
|
app = FastAPI(
|
|
title="Dateiverwaltung",
|
|
description="Modulares Dokumenten-Management-System",
|
|
version="2.0.3",
|
|
lifespan=lifespan
|
|
)
|
|
|
|
# Statische Dateien
|
|
frontend_dir = BASE_DIR / "frontend"
|
|
app.mount("/static", StaticFiles(directory=frontend_dir / "static"), name="static")
|
|
|
|
# Templates
|
|
templates = Jinja2Templates(directory=frontend_dir / "templates")
|
|
|
|
# API Router
|
|
app.include_router(api_router)
|
|
|
|
|
|
@app.get("/", response_class=HTMLResponse)
|
|
async def index(request: Request):
|
|
"""Hauptseite"""
|
|
return templates.TemplateResponse("index.html", {"request": request})
|
|
|
|
|
|
@app.get("/health")
|
|
async def health():
|
|
"""Health Check für Docker"""
|
|
return {"status": "ok"}
|
|
|
|
|
|
if __name__ == "__main__":
|
|
import uvicorn
|
|
uvicorn.run(app, host="0.0.0.0", port=8000)
|