Skip to content

Commit d003de7

Browse files
Read version from pyproject.toml in health endpoint
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent ef99e5f commit d003de7

2 files changed

Lines changed: 17 additions & 3 deletions

File tree

CLAUDE.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
Read other instructions from AGENTS.md
2-
1+
@AGENTS.md
32

43
## CRITICAL: File Editing on Windows
54

data/views/health.py

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

7+
import os
8+
import tomllib
9+
from pathlib import Path
10+
711
from django.http import JsonResponse
812

913

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+
1025
def health_view(request):
1126
"""
1227
Health check endpoint that returns the current version.
@@ -16,5 +31,5 @@ def health_view(request):
1631
"""
1732
return JsonResponse({
1833
"status": "ok",
19-
"version": "0.1.0",
34+
"version": get_version(),
2035
})

0 commit comments

Comments
 (0)