Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,38 +1,90 @@
|
|
| 1 |
from fastapi import FastAPI, Request
|
| 2 |
-
from fastapi.responses import
|
| 3 |
-
|
| 4 |
-
from server import mcp #
|
| 5 |
import datetime
|
|
|
|
| 6 |
|
| 7 |
-
app = FastAPI()
|
| 8 |
|
| 9 |
-
#
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
def update_time():
|
| 23 |
-
return datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
| 24 |
-
|
| 25 |
-
btn.click(update_time, outputs=last_check)
|
| 26 |
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
if __name__ == "__main__":
|
| 38 |
import uvicorn
|
|
|
|
| 1 |
from fastapi import FastAPI, Request
|
| 2 |
+
from fastapi.responses import HTMLResponse
|
| 3 |
+
from fastapi.staticfiles import StaticFiles
|
| 4 |
+
from server import mcp # Tu servidor MCP original
|
| 5 |
import datetime
|
| 6 |
+
import socket
|
| 7 |
|
| 8 |
+
app = FastAPI(title="MCP Server")
|
| 9 |
|
| 10 |
+
# Montar archivos estáticos (opcional, para CSS/images)
|
| 11 |
+
# app.mount("/static", StaticFiles(directory="static"), name="static")
|
| 12 |
+
|
| 13 |
+
@app.get("/", response_class=HTMLResponse)
|
| 14 |
+
async def dashboard(request: Request):
|
| 15 |
+
"""Dashboard principal con información del servidor"""
|
| 16 |
+
hostname = socket.gethostname()
|
| 17 |
+
current_time = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
| 18 |
+
|
| 19 |
+
html_content = f"""
|
| 20 |
+
<!DOCTYPE html>
|
| 21 |
+
<html lang="es">
|
| 22 |
+
<head>
|
| 23 |
+
<meta charset="UTF-8">
|
| 24 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 25 |
+
<title>MCP Server Dashboard</title>
|
| 26 |
+
<style>
|
| 27 |
+
body {{
|
| 28 |
+
font-family: Arial, sans-serif;
|
| 29 |
+
line-height: 1.6;
|
| 30 |
+
margin: 0;
|
| 31 |
+
padding: 20px;
|
| 32 |
+
max-width: 800px;
|
| 33 |
+
margin: auto;
|
| 34 |
+
color: #333;
|
| 35 |
+
}}
|
| 36 |
+
.header {{
|
| 37 |
+
background-color: #f0f0f0;
|
| 38 |
+
padding: 20px;
|
| 39 |
+
border-radius: 5px;
|
| 40 |
+
margin-bottom: 20px;
|
| 41 |
+
}}
|
| 42 |
+
.status-card {{
|
| 43 |
+
background-color: #e8f5e9;
|
| 44 |
+
padding: 15px;
|
| 45 |
+
border-radius: 5px;
|
| 46 |
+
margin-bottom: 20px;
|
| 47 |
+
}}
|
| 48 |
+
.endpoints {{
|
| 49 |
+
background-color: #e3f2fd;
|
| 50 |
+
padding: 15px;
|
| 51 |
+
border-radius: 5px;
|
| 52 |
+
}}
|
| 53 |
+
.last-update {{
|
| 54 |
+
font-size: 0.8em;
|
| 55 |
+
color: #666;
|
| 56 |
+
text-align: right;
|
| 57 |
+
margin-top: 20px;
|
| 58 |
+
}}
|
| 59 |
+
</style>
|
| 60 |
+
</head>
|
| 61 |
+
<body>
|
| 62 |
+
<div class="header">
|
| 63 |
+
<h1>🏥 Pharma IA - MCP Server</h1>
|
| 64 |
+
</div>
|
| 65 |
|
| 66 |
+
<div class="status-card">
|
| 67 |
+
<h2>Estado del Servidor</h2>
|
| 68 |
+
<p>✅ <strong>Servidor activo</strong></p>
|
| 69 |
+
<p>Host: {hostname}</p>
|
| 70 |
+
<p>Hora del servidor: {current_time}</p>
|
| 71 |
+
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
|
| 73 |
+
<div class="endpoints">
|
| 74 |
+
<h2>Endpoints Disponibles</h2>
|
| 75 |
+
<ul>
|
| 76 |
+
<li><strong>/get_document_info</strong> - Obtener información de documentos</li>
|
| 77 |
+
<li><strong>/sse</strong> - Stream de eventos en tiempo real</li>
|
| 78 |
+
</ul>
|
| 79 |
+
</div>
|
| 80 |
+
|
| 81 |
+
<div class="last-update">
|
| 82 |
+
Actualizado: {current_time}
|
| 83 |
+
</div>
|
| 84 |
+
</body>
|
| 85 |
+
</html>
|
| 86 |
+
"""
|
| 87 |
+
return HTMLResponse(content=html_content)
|
| 88 |
|
| 89 |
if __name__ == "__main__":
|
| 90 |
import uvicorn
|