import os
import sys

# Get the directory where this file is located
BASE_DIR = os.path.dirname(os.path.abspath(__file__))

# Add the src directory to Python path
sys.path.insert(0, os.path.join(BASE_DIR, 'src'))

# Load environment variables BEFORE Django loads
env_file = os.path.join(BASE_DIR, '.env')
if os.path.exists(env_file):
    with open(env_file) as f:
        for line in f:
            line = line.strip()
            if line and not line.startswith('#') and '=' in line:
                key, value = line.split('=', 1)
                os.environ[key] = value

# Now set Django settings and import
os.environ['DJANGO_SETTINGS_MODULE'] = 'config.settings.production'

from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
