feat(l4d2-web): scaffold flask app and health endpoint

This commit is contained in:
mwiegand 2026-04-23 01:02:33 +02:00
parent 466abe66ee
commit 4193ce3b4e
No known key found for this signature in database
6 changed files with 61 additions and 0 deletions

View file

@ -0,0 +1 @@
# l4d2-web-app

View file

@ -0,0 +1,22 @@
[build-system]
requires = ["setuptools>=68", "wheel"]
build-backend = "setuptools.build_meta"
[project]
name = "l4d2web"
version = "0.1.0"
description = "L4D2 web app"
readme = "README.md"
requires-python = ">=3.12"
dependencies = [
"Flask>=3.0",
"SQLAlchemy>=2.0",
"alembic>=1.13",
"PyYAML>=6.0",
]
[tool.setuptools]
package-dir = {"" = "src"}
[tool.setuptools.packages.find]
where = ["src"]

View file

@ -0,0 +1,3 @@
__all__ = ["__version__"]
__version__ = "0.1.0"

View file

@ -0,0 +1,16 @@
from flask import Flask, jsonify
from l4d2web.config import DEFAULT_CONFIG
def create_app(test_config: dict[str, object] | None = None) -> Flask:
app = Flask(__name__)
app.config.from_mapping(DEFAULT_CONFIG)
if test_config is not None:
app.config.update(test_config)
@app.get("/health")
def health():
return jsonify({"status": "ok"})
return app

View file

@ -0,0 +1,8 @@
DEFAULT_CONFIG: dict[str, object] = {
"SECRET_KEY": "dev",
"DATABASE_URL": "sqlite:///l4d2web.db",
"STATUS_REFRESH_SECONDS": 8,
"JOB_WORKER_THREADS": 4,
"JOB_LOG_REPLAY_LIMIT": 2000,
"JOB_LOG_LINE_MAX_CHARS": 4096,
}

View file

@ -0,0 +1,11 @@
from l4d2web.app import create_app
def test_health_endpoint() -> None:
app = create_app({"TESTING": True})
client = app.test_client()
response = client.get("/health")
assert response.status_code == 200
assert response.get_json() == {"status": "ok"}