"""
WSGI config for Loadboard project.

It exposes the WSGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/5.2/howto/deployment/wsgi/
"""

import os
from pathlib import Path

# Load .env before Django so DJANGO_* vars are available to settings (Apache mod_wsgi)
_env = Path(__file__).resolve().parent.parent / '.env'
if _env.exists():
    with open(_env) as f:
        for line in f:
            line = line.strip()
            if line and not line.startswith('#') and '=' in line:
                key, _, val = line.partition('=')
                key, val = key.strip(), val.strip().strip('"\'')
                if key and key not in os.environ:
                    os.environ[key] = val

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'Loadboard.settings')

from django.core.wsgi import get_wsgi_application

application = get_wsgi_application()
