Доделал последнюю версию

This commit is contained in:
2025-02-15 02:16:43 +03:00
parent 465df94f07
commit b156930709
15 changed files with 622 additions and 87 deletions
+45
View File
@@ -0,0 +1,45 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Arduino State</title>
<style>
#circle {
width: 100px;
height: 100px;
border-radius: 50%;
margin: 20px;
}
</style>
</head>
<body>
<h1>Состояние пина Arduino</h1>
<p>Подключено к порту: <strong>{{ arduino_port }}</strong></p>
<div id="circle"></div>
<p>Текущее состояние: <span id="pin-state">Загрузка...</span></p>
<script>
function updateCircleColor() {
fetch('/state')
.then(response => response.text())
.then(state => {
let circle = document.getElementById('circle');
let pinStateText = document.getElementById('pin-state');
if (state == '1') {
circle.style.backgroundColor = 'green';
pinStateText.innerHTML = 'Включено';
} else {
circle.style.backgroundColor = 'red';
pinStateText.innerHTML = 'Выключено';
}
})
.catch(error => console.log('Error fetching state:', error));
}
// Обновляем состояние каждые 1000 мс
setInterval(updateCircleColor, 1000);
</script>
</body>
</html>