File size: 2,106 Bytes
783d70f
 
 
908521c
d3a684d
 
783d70f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5fc7d23
 
d3a684d
5fc7d23
 
d3a684d
 
 
5fc7d23
d3a684d
 
 
d769b6c
d3a684d
d769b6c
d3a684d
d769b6c
d3a684d
5fc7d23
d3a684d
 
5fc7d23
 
d3a684d
 
5fc7d23
 
d3a684d
 
 
d769b6c
d3a684d
 
 
5fc7d23
 
 
 
 
 
d3a684d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
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

# Configuraci贸n b谩sica
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)

# Verificar variables de entorno
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.")

# Inicializar la conexi贸n a la base de datos
if not initialize_database_connections():
    raise ValueError("No se pudo inicializar la conexi贸n a la base de datos.")

def main_interface():
    """
    Ruta principal para seleccionar entre Landing Page y Login.
    """
    with gr.Blocks() as app_interface:
        # Contenedores para las interfaces
        landing_container = gr.Group(visible=True)
        login_container = gr.Group(visible=False)

        # Crear interfaces
        landing_page = create_landing_interface()
        login_page = create_login_interface()

        def handle_navigation(page="landing"):
            """
            Maneja la navegaci贸n 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),
            }

        # Landing Page
        with landing_container:
            landing_page.render(navigate_to_login=lambda: handle_navigation("login"))

        # Login Page
        with login_container:
            login_page.render(navigate_back=lambda: handle_navigation("landing"))

    return app_interface

# Lanzar la aplicaci贸n
if __name__ == "__main__":
    app = main_interface()
    app.launch(server_name="0.0.0.0", server_port=7860, auth=None)