geronimo-pericoli commited on
Commit
7247de3
·
verified ·
1 Parent(s): 7c084a4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -50
app.py CHANGED
@@ -1,68 +1,43 @@
 
1
  import gradio as gr
2
  from fastapi import FastAPI
3
- import os
4
- import socket
5
- import platform
6
- import datetime
7
  from server import mcp # Importa tu servidor MCP existente
8
 
9
  # Crea la aplicación FastAPI
10
  app = FastAPI(title="MCP Server Dashboard")
11
 
12
- def get_system_info():
13
- """Obtiene información del sistema"""
14
- return {
15
- "hostname": socket.gethostname(),
16
- "python_version": platform.python_version(),
17
- "system": platform.system(),
18
- "cpu_count": os.cpu_count(),
19
- "current_time": datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
20
- }
21
-
22
- def get_mcp_info():
23
- """Obtiene información del servidor MCP"""
24
- return {
25
- "server_name": "OnBase MCP Server",
26
- "status": "Running",
27
- "port": 7860,
28
- "endpoints": [
29
- {"name": "Document Info", "path": "/get_document_info"},
30
- {"name": "SSE Stream", "path": "/sse"}
31
- ]
32
- }
33
-
34
- def create_dashboard():
35
- """Crea la interfaz de Gradio"""
36
- system_info = get_system_info()
37
- mcp_info = get_mcp_info()
38
-
39
- with gr.Blocks(title="MCP Server Dashboard") as demo:
40
- gr.Markdown("# MCP Server Dashboard")
41
 
42
  with gr.Row():
43
- with gr.Column():
44
- gr.Markdown("## System Information")
45
- gr.JSON(value=system_info, label="System Info")
46
-
47
- with gr.Column():
48
- gr.Markdown("## MCP Server Information")
49
- gr.JSON(value=mcp_info, label="MCP Server Info")
 
 
 
 
50
 
51
- with gr.Row():
52
- gr.Markdown("### Active Endpoints")
53
- endpoints_list = "\n".join([f"- {ep['name']}: `{ep['path']}`" for ep in mcp_info['endpoints']])
54
- gr.Markdown(endpoints_list)
55
 
56
  return demo
57
 
58
- # Crea la interfaz Gradio
59
- gradio_app = create_dashboard()
60
-
61
- # Monta la aplicación Gradio en FastAPI
62
  app = gr.mount_gradio_app(app, gradio_app, path="/")
63
 
64
- # Incluye los endpoints de MCP directamente en la aplicación principal
65
- app.include_router(mcp.router)
66
 
67
  if __name__ == "__main__":
68
  import uvicorn
 
1
+ # app.py
2
  import gradio as gr
3
  from fastapi import FastAPI
 
 
 
 
4
  from server import mcp # Importa tu servidor MCP existente
5
 
6
  # Crea la aplicación FastAPI
7
  app = FastAPI(title="MCP Server Dashboard")
8
 
9
+ # Interfaz simple de Gradio
10
+ def create_simple_interface():
11
+ with gr.Blocks(title="MCP Server Monitor") as demo:
12
+ gr.Markdown("## MCP Server Status")
13
+ gr.Markdown("El servidor MCP está funcionando correctamente.")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
 
15
  with gr.Row():
16
+ # Botón para verificar estado
17
+ status_btn = gr.Button("Verificar estado del servidor")
18
+ status_output = gr.Textbox(label="Estado")
19
+
20
+ def check_status():
21
+ return " Servidor activo y funcionando en el puerto 7860"
22
+
23
+ status_btn.click(
24
+ fn=check_status,
25
+ outputs=status_output
26
+ )
27
 
28
+ # Sección de endpoints disponibles
29
+ gr.Markdown("### Endpoints disponibles:")
30
+ gr.Markdown("- `/get_document_info`: Obtiene información de documentos")
31
+ gr.Markdown("- `/sse`: Stream de eventos (SSE)")
32
 
33
  return demo
34
 
35
+ # Monta la interfaz de Gradio en la ruta principal
36
+ gradio_app = create_simple_interface()
 
 
37
  app = gr.mount_gradio_app(app, gradio_app, path="/")
38
 
39
+ # Si necesitas integrar el MCP de otra forma (ajusta según tu implementación)
40
+ # app.mount("/mcp", mcp.app) # Opción alternativa si mcp tiene una propiedad app
41
 
42
  if __name__ == "__main__":
43
  import uvicorn