P-0000: Register-Dienst (Minimalfassung) mit FastAPI und SQLite, Sendebefehl projekt_id.sh, Tests projekt2id.2 und .3

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-03 10:48:39 +01:00
parent 8453e77153
commit c7f33b46bc
12 changed files with 848 additions and 3 deletions

35
server/register/app.py Normal file
View File

@ -0,0 +1,35 @@
"""FastAPI-Anwendung des Registers. Kein Login in dieser Fassung (kommt mit #1022); gebunden wird nur an lokale Adressen, siehe run.py."""
from fastapi import FastAPI, HTTPException
from pydantic import BaseModel, Field
from .db import Register
from .normalize import normalisiere
class Anfrage(BaseModel):
name: str = Field(min_length=1, max_length=200)
git_adresse: str = Field(min_length=1, max_length=500)
rechner: str = Field(min_length=1, max_length=200)
def erzeuge_app(db_pfad: str) -> FastAPI:
reg = Register(db_pfad)
app = FastAPI(title="Register", docs_url=None, redoc_url=None, openapi_url=None)
@app.get("/api/health")
def health():
return {"ok": True}
@app.post("/api/register")
def register(a: Anfrage):
try:
norm = normalisiere(a.git_adresse)
except ValueError as e:
raise HTTPException(status_code=422, detail=str(e))
return reg.anfrage(a.name.strip(), norm, a.git_adresse.strip(), a.rechner.strip())
@app.get("/api/projekte")
def projekte():
return reg.liste()
return app