geronimo-pericoli commited on
Commit
9082543
verified
1 Parent(s): df8dd91

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -18
app.py CHANGED
@@ -1,18 +1,14 @@
1
- from fastapi import FastAPI, Request
2
- from fastapi.responses import HTMLResponse
3
- from fastapi.templating import Jinja2Templates
4
  import os
5
  import socket
6
- import datetime
7
  import platform
 
8
  from server import mcp # Importa tu servidor MCP existente
9
 
10
  # Crea la aplicaci贸n FastAPI
11
  app = FastAPI(title="MCP Server Dashboard")
12
 
13
- # Configurar templates
14
- templates = Jinja2Templates(directory="templates")
15
-
16
  def get_system_info():
17
  """Obtiene informaci贸n del sistema"""
18
  return {
@@ -23,11 +19,9 @@ def get_system_info():
23
  "current_time": datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
24
  }
25
 
26
- @app.get("/", response_class=HTMLResponse)
27
- async def dashboard(request: Request):
28
- """Dashboard principal con informaci贸n del servidor"""
29
- system_info = get_system_info()
30
- mcp_info = {
31
  "server_name": "OnBase MCP Server",
32
  "status": "Running",
33
  "port": 7860,
@@ -36,13 +30,36 @@ async def dashboard(request: Request):
36
  {"name": "SSE Stream", "path": "/sse"}
37
  ]
38
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
 
40
- return templates.TemplateResponse("dashboard.html", {
41
- "request": request,
42
- "system_info": system_info,
43
- "mcp_info": mcp_info,
44
- "title": "MCP Server Dashboard"
45
- })
 
46
 
47
  # Incluye los endpoints de MCP directamente en la aplicaci贸n principal
48
  app.include_router(mcp.router)
 
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 {
 
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,
 
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)