diff --git a/aviso_core/middlewares.py b/aviso_core/middlewares.py index 82a1cb4..0d73a87 100644 --- a/aviso_core/middlewares.py +++ b/aviso_core/middlewares.py @@ -16,6 +16,9 @@ def __init__(self, get_response): self.get_response = get_response def __call__(self, request): + if request.path.rstrip("/") == "/gbm/health": + return self.get_response(request) + # =========================================================== # 1. REQUEST PHASE: Initialize Context # =========================================================== diff --git a/aviso_core/settings.py b/aviso_core/settings.py index f251ba5..d22ede9 100644 --- a/aviso_core/settings.py +++ b/aviso_core/settings.py @@ -25,16 +25,10 @@ DEBUG = os.environ.get('DEBUG', 'True') == 'True' # --- LOGIC FOR ALLOWED HOSTS --- -if DEBUG: - # Local development - ALLOWED_HOSTS = ['localhost', '127.0.0.1', '0.0.0.0'] - CSRF_TRUSTED_ORIGINS = ["http://localhost:8000", "http://127.0.0.1:8000"] -else: - ALLOWED_HOSTS = os.environ.get('ALLOWED_HOSTS', '').split(',') - trusted_origins = os.environ.get('TRUSTED_ORIGINS', '').split(',') - CSRF_TRUSTED_ORIGINS = [origin.strip() for origin in trusted_origins if origin.strip()] -# Application definition +ALLOWED_HOSTS = os.environ.get('ALLOWED_HOSTS', '').split(',') +trusted_origins = os.environ.get('TRUSTED_ORIGINS', '').split(',') +CSRF_TRUSTED_ORIGINS = [origin.strip() for origin in trusted_origins if origin.strip()] INSTALLED_APPS = [ 'django.contrib.admin', @@ -89,6 +83,26 @@ } +# if DEBUG: +# DATABASES = { +# "default": { +# "ENGINE": "django.db.backends.sqlite3", +# "NAME": BASE_DIR / "db.sqlite3", +# } +# } +# else: +# DATABASES = { +# "default": { +# "ENGINE": "django.db.backends.postgresql", +# "NAME": os.environ.get("DB_NAME"), +# "USER": os.environ.get("DB_USER"), +# "PASSWORD": os.environ.get("DB_PASSWORD"), +# "HOST": os.environ.get("DB_HOST"), +# "PORT": os.environ.get("DB_PORT", "5432"), +# } +# } + + # Password validation # https://docs.djangoproject.com/en/5.2/ref/settings/#auth-password-validators diff --git a/gbm_apis/api/health.py b/gbm_apis/api/health.py index d5aa094..d232c0f 100644 --- a/gbm_apis/api/health.py +++ b/gbm_apis/api/health.py @@ -3,7 +3,7 @@ from django.views import View from django.utils.decorators import method_decorator from django.views.decorators.csrf import csrf_exempt -from django.db import connection +# from django.db import connection from django.conf import settings logger = logging.getLogger(f'gnana.{__name__}') @@ -26,8 +26,8 @@ def get(self, request): try: ## TODO Mongo HEalth CHeck - with connection.cursor() as cursor: - cursor.execute("SELECT 1") + # with connection.cursor() as cursor: + # cursor.execute("SELECT 1") health_status["checks"]["database"] = "ok" except Exception as db_error: logger.warning(f"Database health check failed: {str(db_error)}")