Add /version endpoint with git hash for deploy verification

This commit is contained in:
russell@unturf.com 2026-02-07 19:38:01 -05:00
parent e9bef9982d
commit 1ebfb5a8aa
2 changed files with 25 additions and 0 deletions

View file

@ -2,6 +2,7 @@ def includeme(config):
config.add_static_view("static", "static", cache_max_age=3600)
config.add_route("favicon", "/favicon.ico")
config.add_route("robots", "/robots.txt")
config.add_route("version", "/version")
# Sitemap and feed routes
config.add_route("sitemap", "/sitemap.xml")

View file

@ -0,0 +1,24 @@
import subprocess
from pyramid.response import Response
from pyramid.view import view_config
# Capture git hash once at process start.
try:
GIT_HASH = (
subprocess.check_output(
["git", "rev-parse", "--short", "HEAD"],
stderr=subprocess.DEVNULL,
)
.decode()
.strip()
)
except Exception:
GIT_HASH = "unknown"
VERSION = "1.1.5"
@view_config(route_name="version", renderer="json")
def version(request):
return {"version": VERSION, "hash": GIT_HASH}