import os
import sys

# Diretorio raiz da aplicacao (ex.: /home/fse3d)
APP_ROOT = os.path.dirname(os.path.abspath(__file__))
if APP_ROOT not in sys.path:
    sys.path.insert(0, APP_ROOT)

INTERP = os.path.join(APP_ROOT, ".venv", "bin", "python")
if os.name != "nt" and sys.executable != INTERP and os.path.exists(INTERP):
    os.execl(INTERP, INTERP, *sys.argv)

from a2wsgi import ASGIMiddleware

from app.main import app as asgi_app

# cPanel/Passenger espera um callable WSGI chamado "application"
application = ASGIMiddleware(asgi_app)
