STONKS/templates/index.html

46 lines
815 B
HTML

<!DOCTYPE html>
<html>
<head>
<title>Dashboard</title>
<link rel="stylesheet" href="/static/style.css">
</head>
<body>
<h2>Main Dashboard</h2>
<a href="/graphs">Go to Graphs</a>
<table id="table"></table>
<script>
async function load() {
const res = await fetch("/api/data");
const data = await res.json();
const table = document.getElementById("table");
if (!data.rows.length) {
table.innerHTML = "<tr><td>No data</td></tr>";
return;
}
const cols = data.columns;
let html = "<tr>" +
cols.map(c => `<th>${c}</th>`).join("") +
"</tr>";
html += data.rows.map(row =>
"<tr>" +
cols.map(c => `<td>${row[c]}</td>`).join("") +
"</tr>"
).join("");
table.innerHTML = html;
}
load();
</script>
</body>
</html>