42 lines
1.2 KiB
HTML
42 lines
1.2 KiB
HTML
|
|
<!DOCTYPE html>
|
||
|
|
<html>
|
||
|
|
<head>
|
||
|
|
<title>ESP32 Dashboard</title>
|
||
|
|
<style>
|
||
|
|
.card {
|
||
|
|
background: #f0f0f0;
|
||
|
|
padding: 20px;
|
||
|
|
margin: 10px;
|
||
|
|
border-radius: 10px;
|
||
|
|
}
|
||
|
|
</style>
|
||
|
|
</head>
|
||
|
|
<body>
|
||
|
|
<div id="dashboard"></div>
|
||
|
|
<script>
|
||
|
|
function updateValues() {
|
||
|
|
console.log('Fetching ESP info...');
|
||
|
|
fetch('/api/espinfo')
|
||
|
|
.then(response => {
|
||
|
|
if (!response.ok) {
|
||
|
|
throw new Error(`HTTP error! status: ${response.status}`);
|
||
|
|
}
|
||
|
|
return response.text();
|
||
|
|
})
|
||
|
|
.then(data => {
|
||
|
|
console.log('Data received');
|
||
|
|
document.getElementById('dashboard').innerHTML = data;
|
||
|
|
})
|
||
|
|
.catch(error => {
|
||
|
|
console.error('Error:', error);
|
||
|
|
document.getElementById('dashboard').innerHTML = 'Error loading data';
|
||
|
|
});
|
||
|
|
}
|
||
|
|
// Initial load
|
||
|
|
updateValues();
|
||
|
|
// Update every 2 seconds
|
||
|
|
setInterval(updateValues, 2000);
|
||
|
|
</script>
|
||
|
|
</body>
|
||
|
|
</html>
|