Skip to content

Commit 052babd

Browse files
Revert "Read VERSION from settings in health endpoint"
This reverts commit 83179a0.
1 parent 6e3c88f commit 052babd

2 files changed

Lines changed: 16 additions & 4 deletions

File tree

course_management/settings.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@
3939
IS_LOCAL = os.getenv("IS_LOCAL", "0") == "1"
4040
print(f"IS_LOCAL={IS_LOCAL}")
4141

42-
VERSION = os.getenv("VERSION", "N/A")
43-
4442
CSRF_TRUSTED_ORIGINS = []
4543

4644
for host in ALLOWED_HOSTS:

data/views/health.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,24 @@
44
Provides a simple health check that returns the current application version.
55
"""
66

7-
from django.conf import settings
7+
import os
8+
import tomllib
9+
from pathlib import Path
10+
811
from django.http import JsonResponse
912

1013

14+
def get_version():
15+
"""Read version from pyproject.toml."""
16+
pyproject_path = Path(__file__).parent.parent.parent / "pyproject.toml"
17+
try:
18+
with open(pyproject_path, "rb") as f:
19+
data = tomllib.load(f)
20+
return data.get("project", {}).get("version", "unknown")
21+
except Exception:
22+
return "unknown"
23+
24+
1125
def health_view(request):
1226
"""
1327
Health check endpoint that returns the current version.
@@ -17,5 +31,5 @@ def health_view(request):
1731
"""
1832
return JsonResponse({
1933
"status": "ok",
20-
"version": getattr(settings, "VERSION", "unknown"),
34+
"version": get_version(),
2135
})

0 commit comments

Comments
 (0)