Spaces:
Sleeping
Sleeping
| from fastapi import FastAPI, Request | |
| from fastapi.responses import HTMLResponse | |
| from fastapi.templating import Jinja2Templates | |
| import os | |
| import socket | |
| import datetime | |
| import platform | |
| from server import mcp # Importa tu servidor MCP existente | |
| # Crea la aplicaci贸n FastAPI | |
| app = FastAPI(title="MCP Server Dashboard") | |
| # Configurar templates | |
| templates = Jinja2Templates(directory="templates") | |
| def get_system_info(): | |
| """Obtiene informaci贸n del sistema""" | |
| return { | |
| "hostname": socket.gethostname(), | |
| "python_version": platform.python_version(), | |
| "system": platform.system(), | |
| "cpu_count": os.cpu_count(), | |
| "current_time": datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") | |
| } | |
| async def dashboard(request: Request): | |
| """Dashboard principal con informaci贸n del servidor""" | |
| system_info = get_system_info() | |
| mcp_info = { | |
| "server_name": "OnBase MCP Server", | |
| "status": "Running", | |
| "port": 7860, | |
| "endpoints": [ | |
| {"name": "Document Info", "path": "/get_document_info"}, | |
| {"name": "SSE Stream", "path": "/sse"} | |
| ] | |
| } | |
| return templates.TemplateResponse("dashboard.html", { | |
| "request": request, | |
| "system_info": system_info, | |
| "mcp_info": mcp_info, | |
| "title": "MCP Server Dashboard" | |
| }) | |
| # Incluye los endpoints de MCP directamente en la aplicaci贸n principal | |
| app.include_router(mcp.router) | |
| if __name__ == "__main__": | |
| import uvicorn | |
| uvicorn.run(app, host="0.0.0.0", port=7860) |