Files
NoN-Site/nonpacks/common/context_processors.py
T

17 lines
578 B
Python

import time
from .os_utils import get_os_info
from django.conf import settings
def app_version(request):
os_icon, os_name = get_os_info()
page_gen_time = ''
if hasattr(request, '_start_time') and request._start_time:
elapsed = time.time() - request._start_time
page_gen_time = f"{elapsed * 1000:.0f}ms"
return {
'APP_ENV': 'dev' if settings.DEBUG else 'prod',
'GIT_COMMIT_HASH': getattr(settings, 'GIT_COMMIT_HASH', 'unknown'),
'OS_ICON': os_icon,
'OS_NAME': os_name,
'PAGE_GEN_TIME': page_gen_time,
}