"""
WSGI config for sistema_titulacion project.

It exposes the WSGI callable as a module-level variable named ``application``.
Este archivo es el punto de entrada que usa cPanel (raíz del proyecto).
"""

import os
import sys
import traceback
from pathlib import Path

from django.core.wsgi import get_wsgi_application

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

try:
    application = get_wsgi_application()
except Exception:
    log_path = Path(__file__).resolve().parent / 'startup_error.log'
    with open(log_path, 'a') as f:
        f.write('\n' + '=' * 60 + '\n')
        f.write(traceback.format_exc())
    raise
