This commit is contained in:
Team3
2026-06-05 19:54:34 +02:00
commit 3ed5f7c3e5
18 changed files with 2670 additions and 0 deletions

5
backend/config.py Normal file
View File

@@ -0,0 +1,5 @@
from pathlib import Path
PROJECT_ROOT = Path(__file__).resolve().parent.parent
FRONTEND_DIST = PROJECT_ROOT / "frontend" / "dist"
DB_PATH = PROJECT_ROOT / "creator.db"

30
backend/database.py Normal file
View File

@@ -0,0 +1,30 @@
import aiosqlite
from config import DB_PATH
_db: aiosqlite.Connection | None = None
async def get_db() -> aiosqlite.Connection:
global _db
if _db is None:
_db = await aiosqlite.connect(DB_PATH)
return _db
async def init_db():
db = await get_db()
# Tabellen folgen, sobald die ersten Features stehen.
await db.commit()
async def close_db():
global _db
if _db is not None:
await _db.close()
_db = None
def _row_to_dict(row, cursor):
columns = [d[0] for d in cursor.description]
return dict(zip(columns, row))

23
backend/main.py Normal file
View File

@@ -0,0 +1,23 @@
from contextlib import asynccontextmanager
from fastapi import FastAPI
from fastapi.staticfiles import StaticFiles
from config import FRONTEND_DIST
from database import init_db, close_db
from routes import router
@asynccontextmanager
async def lifespan(app: FastAPI):
await init_db()
yield
await close_db()
app = FastAPI(title="Creator", lifespan=lifespan)
app.include_router(router)
if FRONTEND_DIST.exists():
app.mount("/", StaticFiles(directory=FRONTEND_DIST, html=True), name="frontend")

3
backend/requirements.txt Normal file
View File

@@ -0,0 +1,3 @@
fastapi
uvicorn[standard]
aiosqlite

8
backend/routes.py Normal file
View File

@@ -0,0 +1,8 @@
from fastapi import APIRouter
router = APIRouter(prefix="/api")
@router.get("/health")
async def health():
return {"ok": True}