feat(l4d2-web): scaffold flask app and health endpoint
This commit is contained in:
parent
466abe66ee
commit
4193ce3b4e
6 changed files with 61 additions and 0 deletions
1
components/l4d2-web-app/README.md
Normal file
1
components/l4d2-web-app/README.md
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
# l4d2-web-app
|
||||||
22
components/l4d2-web-app/pyproject.toml
Normal file
22
components/l4d2-web-app/pyproject.toml
Normal 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"]
|
||||||
3
components/l4d2-web-app/src/l4d2web/__init__.py
Normal file
3
components/l4d2-web-app/src/l4d2web/__init__.py
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
__all__ = ["__version__"]
|
||||||
|
|
||||||
|
__version__ = "0.1.0"
|
||||||
16
components/l4d2-web-app/src/l4d2web/app.py
Normal file
16
components/l4d2-web-app/src/l4d2web/app.py
Normal 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
|
||||||
8
components/l4d2-web-app/src/l4d2web/config.py
Normal file
8
components/l4d2-web-app/src/l4d2web/config.py
Normal 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,
|
||||||
|
}
|
||||||
11
components/l4d2-web-app/tests/test_health.py
Normal file
11
components/l4d2-web-app/tests/test_health.py
Normal 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"}
|
||||||
Loading…
Reference in a new issue