File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44Provides a simple health check that returns the current application version.
55"""
66
7- import os
8- import tomllib
9- from pathlib import Path
10-
7+ from django .conf import settings
118from django .http import JsonResponse
129
1310
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-
2511def health_view (request ):
2612 """
2713 Health check endpoint that returns the current version.
@@ -31,5 +17,5 @@ def health_view(request):
3117 """
3218 return JsonResponse ({
3319 "status" : "ok" ,
34- "version" : get_version ( ),
20+ "version" : getattr ( settings , "VERSION" , "unknown" ),
3521 })
You can’t perform that action at this time.
0 commit comments