Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
"
|
| 16 |
-
"
|
| 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 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
|
| 56 |
return demo
|
| 57 |
|
| 58 |
-
#
|
| 59 |
-
gradio_app =
|
| 60 |
-
|
| 61 |
-
# Monta la aplicación Gradio en FastAPI
|
| 62 |
app = gr.mount_gradio_app(app, gradio_app, path="/")
|
| 63 |
|
| 64 |
-
#
|
| 65 |
-
app.
|
| 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
|