From 1549acb90ba27cbf455fc65c09069d05251d28c0 Mon Sep 17 00:00:00 2001 From: Pino Date: Wed, 10 Jun 2026 07:44:42 +0200 Subject: [PATCH] =?UTF-8?q?code:=20Grundger=C3=BCst=20und=20FastAPI-Health?= =?UTF-8?q?-Endpoint?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 35 ++++++++++------------------------- app/main.py | 17 +++++++++++++++++ pyproject.toml | 28 ++++++++++++++++++++++++++++ tests/test_health.py | 10 ++++++++++ 4 files changed, 65 insertions(+), 25 deletions(-) create mode 100644 app/main.py create mode 100644 pyproject.toml create mode 100644 tests/test_health.py diff --git a/.gitignore b/.gitignore index 7e8bf15..fcf17b6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,27 +1,12 @@ -# Projekt-Scope: thesillyhome-reanalysis -# Vermeide Störungen aus dem übergeordneten Workspace. - -# Isolation: projektinterne Hüterdateien ignorieren, -# aber keine Steuerdateien aus dem Workspace-Root stumm abschalten. -!memory/ -!memory/* -!second-brain/ -!second-brain/* - -# Secrets und Umgebungsvariablen +/venv +/.venv +/.idea +/.vscode +__pycache__/ +*.pyc +.mypy_cache/ +.pytest_cache/ +.ruff_cache/ .env .env.local -.env.*.local - -# Vermischte Backup- und temporäre Dateien -*.sqlite.bak -*.sqlite.bak-* -*.log -*.tmp -*.swp -*.swo - -# Editor/IDE -.idea -.vscode -*.code-workspace +.env.* diff --git a/app/main.py b/app/main.py new file mode 100644 index 0000000..de0f8ff --- /dev/null +++ b/app/main.py @@ -0,0 +1,17 @@ +from fastapi import FastAPI + +app = FastAPI( + title="SillyHome Next API", + description="Lokales Smart-Home-Intelligenzsystem für Home Assistant.", + version="0.1.0", +) + + +@app.get("/health") +def health() -> dict[str, str]: + return {"status": "ok"} + + +@app.get("/") +def root() -> dict[str, str]: + return {"service": "sillyhome-next", "docs": "/docs"} diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..c28b433 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,28 @@ +[project] +name = "sillyhome-next" +version = "0.1.0" +description = "Lokales Smart-Home-Intelligenzsystem für Home Assistant" +requires-python = ">=3.11" +dependencies = [ + "fastapi>=0.110.0", + "uvicorn[standard]>=0.29.0", + "pydantic>=2.6.0", +] + +[project.optional-dependencies] +dev = [ + "pytest>=8.0.0", + "ruff>=0.4.0", + "mypy>=1.9.0", +] + +[tool.pytest.ini_options] +testpaths = ["tests"] +addopts = "-q" + +[tool.mypy] +strict = true + +[tool.ruff] +line-length = 100 +target-version = "py311" diff --git a/tests/test_health.py b/tests/test_health.py new file mode 100644 index 0000000..83a4062 --- /dev/null +++ b/tests/test_health.py @@ -0,0 +1,10 @@ +from fastapi.testclient import TestClient +from app.main import app + +client = TestClient(app) + + +def test_health_returns_ok() -> None: + response = client.get("/health") + assert response.status_code == 200 + assert response.json() == {"status": "ok"}