geronimo-pericoli commited on
Commit
d53b837
verified
1 Parent(s): 1261e21

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +59 -8
app.py CHANGED
@@ -1,8 +1,59 @@
1
- # app.py
2
- from server import mcp
3
-
4
- # Hugging Face Spaces ejecutar谩 este archivo, pero nuestra l贸gica principal est谩 en server.py
5
- # Esto es solo un punto de entrada para Spaces
6
- if __name__ == "__main__":
7
- print("馃殌 Starting server from Hugging Face Space...")
8
- mcp.run("sse")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import FastAPI, Request
2
+ from fastapi.responses import HTMLResponse
3
+ from fastapi.staticfiles import StaticFiles
4
+ from fastapi.templating import Jinja2Templates
5
+ import os
6
+ import socket
7
+ import datetime
8
+ import platform
9
+ from typing import Optional
10
+ from server import mcp # Importa tu servidor MCP existente
11
+
12
+ app = FastAPI(title="MCP Server Dashboard")
13
+
14
+ # Montar directorio est谩tico (para CSS/im谩genes si quieres)
15
+ app.mount("/static", StaticFiles(directory="static"), name="static")
16
+
17
+ # Configurar templates
18
+ templates = Jinja2Templates(directory="templates")
19
+
20
+ def get_system_info():
21
+ """Obtiene informaci贸n del sistema"""
22
+ return {
23
+ "hostname": socket.gethostname(),
24
+ "ip": socket.gethostbyname(socket.gethostname()),
25
+ "python_version": platform.python_version(),
26
+ "system": platform.system(),
27
+ "memory": os.sysconf('SC_PAGE_SIZE') * os.sysconf('SC_PHYS_PAGES') / (1024.**3) if hasattr(os, 'sysconf') else "N/A",
28
+ "cpu_count": os.cpu_count(),
29
+ "uptime": datetime.datetime.now() - datetime.datetime.fromtimestamp(os.getpid()),
30
+ "current_time": datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
31
+ }
32
+
33
+ @app.get("/", response_class=HTMLResponse)
34
+ async def dashboard(request: Request):
35
+ """Dashboard principal con informaci贸n del servidor"""
36
+ system_info = get_system_info()
37
+ mcp_info = {
38
+ "server_name": "OnBase MCP Server",
39
+ "status": "Running",
40
+ "port": 7860,
41
+ "endpoints": [
42
+ {"name": "Document Info", "path": "/get_document_info"},
43
+ {"name": "SSE Stream", "path": "/sse"}
44
+ ]
45
+ }
46
+
47
+ return templates.TemplateResponse("dashboard.html", {
48
+ "request": request,
49
+ "system_info": system_info,
50
+ "mcp_info": mcp_info,
51
+ "title": "MCP Server Dashboard"
52
+ })
53
+
54
+ # Montar los endpoints de MCP bajo /api
55
+ app.mount("/api", mcp.app)
56
+
57
+ if __name__ == "__main__":
58
+ import uvicorn
59
+ uvicorn.run(app, host="0.0.0.0", port=7860)