File size: 2,092 Bytes
d811bac
14fb0b3
d811bac
 
6220666
d811bac
14fb0b3
6220666
dbf68bb
f857d39
6220666
 
 
 
 
 
 
ec48fc4
 
 
 
 
6220666
 
ec48fc4
6220666
ec48fc4
6220666
 
ec48fc4
dbf68bb
ec48fc4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5fb9fb8
ec48fc4
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
import gradio as gr
import requests
import time

def test_antena(ip, usuario, password):
    try:
        session = requests.Session()
        login_url = f"http://{ip}/api/login"
        login_data = {"username": usuario, "password": password}
        
        response = session.post(login_url, json=login_data, timeout=10)
        
        if response.status_code == 200:
            status_url = f"http://{ip}/api/v1/status"
            status_response = session.get(status_url, timeout=10)
            
            if status_response.status_code == 200:
                resultado = "✅ CONEXIÓN EXITOSA\n\n"
                resultado += f"IP: {ip}\n"
                resultado += f"Usuario: {usuario}\n"
                resultado += f"Hora: {time.strftime('%H:%M:%S')}\n\n"
                resultado += "📊 Métricas obtenidas correctamente via API"
                return resultado
            else:
                return f"⚠️ LOGIN OK pero no métricas\n\nError status: {status_response.status_code}"
        else:
            return f"❌ ERROR DE LOGIN\n\nCódigo: {response.status_code}"
            
    except Exception as e:
        return f"🔴 ERROR DE CONEXIÓN\n\nDetalle: {str(e)}"

# Interfaz con área de resultados GRANDE
with gr.Blocks() as demo:
    gr.Markdown("# 📡 TEST UBIQUITI")
    
    with gr.Row():
        with gr.Column(scale=1):
            ip_input = gr.Textbox(label="IP del equipo", value="192.168.1.24")
            user_input = gr.Textbox(label="Usuario", value="admin")
            pass_input = gr.Textbox(label="Contraseña", type="password")
            btn = gr.Button("🚀 EJECUTAR TEST", variant="primary")
        
        with gr.Column(scale=2):
            # Área de resultados MÁS GRANDE
            output = gr.Textbox(
                label="RESULTADOS", 
                lines=10,  # 10 líneas de alto
                max_lines=20,
                show_copy_button=True
            )
    
    btn.click(
        fn=test_antena,
        inputs=[ip_input, user_input, pass_input],
        outputs=output
    )

demo.launch()