|
import gradio as gr |
|
import os |
|
import logging |
|
|
|
from modules.ui.landing_ui import create_landing_interface |
|
from modules.ui.login_ui import create_login_interface |
|
from modules.database.database_init import initialize_database_connections |
|
|
|
|
|
logging.basicConfig(level=logging.INFO) |
|
logger = logging.getLogger(__name__) |
|
|
|
|
|
COSMOS_ENDPOINT = os.getenv("COSMOS_ENDPOINT") |
|
COSMOS_KEY = os.getenv("COSMOS_KEY") |
|
if not COSMOS_ENDPOINT or not COSMOS_KEY: |
|
raise ValueError("Faltan variables de entorno: COSMOS_ENDPOINT y COSMOS_KEY.") |
|
|
|
|
|
if not initialize_database_connections(): |
|
raise ValueError("No se pudo inicializar la conexi贸n a la base de datos.") |
|
|
|
def main_interface(): |
|
""" |
|
Crea la interfaz principal con redirecci贸n al login o landing. |
|
""" |
|
with gr.Blocks() as app_interface: |
|
|
|
landing_container = gr.Group(visible=True) |
|
login_container = gr.Group(visible=False) |
|
|
|
|
|
landing_page = create_landing_interface() |
|
login_page = create_login_interface() |
|
|
|
|
|
def handle_navigation(page="landing"): |
|
""" |
|
Redirige entre Landing Page y Login. |
|
""" |
|
if page == "login": |
|
return { |
|
landing_container: gr.update(visible=False), |
|
login_container: gr.update(visible=True), |
|
} |
|
return { |
|
landing_container: gr.update(visible=True), |
|
login_container: gr.update(visible=False), |
|
} |
|
|
|
|
|
with landing_container: |
|
landing_page(navigate_to_login=lambda: handle_navigation("login")) |
|
|
|
|
|
with login_container: |
|
login_page(navigate_back=lambda: handle_navigation("landing")) |
|
|
|
return app_interface |
|
|
|
|
|
if __name__ == "__main__": |
|
app = main_interface() |
|
app.launch(server_name="0.0.0.0", server_port=7860, auth=None) |
|
|