46 lines
1.5 KiB
HTML
46 lines
1.5 KiB
HTML
<!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>
|