Spaces:
Running
Running
| <html lang="it"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <title>Environmental Monitor</title> | |
| <style> | |
| :root { | |
| --glass: rgba(255, 255, 255, 0.15); | |
| --border: rgba(255, 255, 255, 0.25); | |
| --ok: #4ade80; | |
| --warn: #facc15; | |
| --err: #f87171; | |
| --text: #f8fafc; | |
| --background: #0f172a; | |
| --highlight: rgba(255, 255, 255, 0.1); | |
| } | |
| * { | |
| box-sizing: border-box; | |
| margin: 0; | |
| padding: 0; | |
| } | |
| body { | |
| margin: 0; | |
| min-height: 100vh; | |
| background: linear-gradient(135deg, #0f172a, #1e293b); | |
| font-family: system-ui, -apple-system, sans-serif; | |
| display: grid; | |
| place-items: center; | |
| color: var(--text); | |
| padding: 20px; | |
| } | |
| .card { | |
| width: 100%; | |
| max-width: 400px; | |
| padding: 40px 30px; | |
| border-radius: 24px; | |
| background: var(--glass); | |
| backdrop-filter: blur(16px); | |
| -webkit-backdrop-filter: blur(16px); | |
| border: 1px solid var(--border); | |
| box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3); | |
| text-align: center; | |
| transition: all 0.3s ease; | |
| } | |
| .card:hover { | |
| transform: translateY(-5px); | |
| box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4); | |
| } | |
| h1 { | |
| margin: 0 0 30px; | |
| font-weight: 600; | |
| font-size: 1.8rem; | |
| letter-spacing: 0.5px; | |
| color: #f8fafc; | |
| position: relative; | |
| display: inline-block; | |
| } | |
| h1::after { | |
| content: ''; | |
| position: absolute; | |
| bottom: -8px; | |
| left: 50%; | |
| transform: translateX(-50%); | |
| width: 60px; | |
| height: 3px; | |
| background: var(--ok); | |
| border-radius: 3px; | |
| } | |
| .metric-container { | |
| display: flex; | |
| flex-direction: column; | |
| gap: 20px; | |
| margin: 30px 0; | |
| } | |
| .metric { | |
| display: flex; | |
| align-items: center; | |
| justify-content: center; | |
| gap: 15px; | |
| font-size: 1.1rem; | |
| padding: 20px; | |
| border-radius: 12px; | |
| background: var(--highlight); | |
| transition: all 0.2s ease; | |
| } | |
| .metric:hover { | |
| background: rgba(255, 255, 255, 0.15); | |
| } | |
| .metric-value { | |
| font-size: 2.2rem; | |
| font-weight: 600; | |
| margin-left: 8px; | |
| } | |
| .metric-icon { | |
| font-size: 1.5rem; | |
| } | |
| .status-container { | |
| margin-top: 30px; | |
| display: flex; | |
| flex-direction: column; | |
| align-items: center; | |
| gap: 8px; | |
| } | |
| .status { | |
| display: flex; | |
| align-items: center; | |
| font-size: 0.9rem; | |
| letter-spacing: 0.5px; | |
| opacity: 0.9; | |
| } | |
| .dot { | |
| display: inline-block; | |
| width: 12px; | |
| height: 12px; | |
| border-radius: 50%; | |
| margin-right: 10px; | |
| background: var(--warn); | |
| box-shadow: 0 0 8px currentColor; | |
| } | |
| .footer { | |
| margin-top: 30px; | |
| font-size: 0.75rem; | |
| opacity: 0.6; | |
| letter-spacing: 0.5px; | |
| } | |
| @media (max-width: 480px) { | |
| .card { | |
| padding: 30px 20px; | |
| } | |
| .metric-value { | |
| font-size: 2rem; | |
| } | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <div class="card"> | |
| <h1>EcoGarden Pulse</h1> | |
| <div class="metric-container"> | |
| <div class="metric"> | |
| <span class="metric-icon">🌡</span> | |
| <span id="temp" class="metric-value">--</span> | |
| <span>°C</span> | |
| </div> | |
| <div class="metric"> | |
| <span class="metric-icon">💧</span> | |
| <span id="hum" class="metric-value">--</span> | |
| <span>%</span> | |
| </div> | |
| </div> | |
| <div class="status-container"> | |
| <div class="status"> | |
| <span class="dot" id="dot"></span> | |
| <span id="status">In attesa dati…</span> | |
| </div> | |
| </div> | |
| <div class="footer"> | |
| EcoGarden Pulse v1.0 · Sensori locali | |
| </div> | |
| </div> | |
| <script> | |
| const REFRESH = {{ refresh }}; | |
| const temp = document.getElementById("temp"); | |
| const hum = document.getElementById("hum"); | |
| const statusText = document.getElementById("status"); | |
| const dot = document.getElementById("dot"); | |
| function setStatus(type, text) { | |
| statusText.textContent = text; | |
| dot.style.background = | |
| type === "ok" ? "var(--ok)" : | |
| type === "err" ? "var(--err)" : | |
| "var(--warn)"; | |
| } | |
| setInterval(() => { | |
| fetch("/data") | |
| .then(r => r.json()) | |
| .then(d => { | |
| if (d.temperature && d.humidity) { | |
| temp.textContent = d.temperature; | |
| hum.textContent = d.humidity; | |
| setStatus("ok", "LIVE"); | |
| } else { | |
| setStatus("warn", "In attesa dati…"); | |
| } | |
| }) | |
| .catch(() => { | |
| setStatus("err", "OFFLINE"); | |
| }); | |
| }, REFRESH); | |
| </script> | |
| </body> | |
| </html> |