# import os
# import sys
# from api.main import app as main_app
# from a2wsgi import ASGIMiddleware


# sys.path.insert(0, os.path.dirname(__file__))


# def application(environ, start_response):
#     start_response('200 OK', [('Content-Type', 'text/plain')])
#     message = 'It works!\n'
#     version = 'Python %s\n' % sys.version.split()[0]
#     response = '\n'.join([message, version])
#     return ASGIMiddleware(main_app)

#  ===============================================================

import os
import sys

# Adiciona o diretório atual ao path para importar módulos locais
sys.path.insert(0, os.path.dirname(__file__))

def application(environ, start_response):
    # Define o status da resposta HTTP
    start_response('200 OK', [('Content-Type', 'text/plain')])
    
    # Cria a mensagem de texto simples
    message = 'It works!\n'
    version = 'Python v' + sys.version.split()[0] + '\n'
    
    # Junta a mensagem com a versão do Python
    response = '\n'.join([message, version])
    
    # Retorna a resposta codificada em bytes (obrigatório no WSGI)
    return [response.encode()]