You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@Berny23 thanks for a great job with this.
If you allow me a suggestion, could you add a button to shutdown the toypad machine (debian)?
I try with this code and work for me:
Change in /index.js
// ---------------------Begin of shutdown----------------------------------------------------
// Importa el módulo 'child_process' para ejecutar comandos del sistema
const { exec } = require('child_process');
// ...
// Ruta para apagar el sistema
app.post('/shutdown', (request, response) => {
// Ejecuta el comando para apagar el sistema
exec('sudo shutdown -h now', (error, stdout, stderr) => {
if (error) {
console.error(Error al apagar el sistema: ${error.message});
response.status(500).send('Error al apagar el sistema');
return;
}
console.log(Sistema apagado: ${stdout});
response.send('El sistema se está apagando...');
});
});
// ---------------------End of shutdown----------------------------------------------------
Change in /server/index.html
Apagar el sistema
<style>
#shutdownButton {
background-color: red;
color: white;
animation: blink 1s infinite;
}
@Keyframes blink {
0% {
opacity: 0;
}
50% {
opacity: 1;
}
100% {
opacity: 0;
}
}
</style>
<script>
// Agrega el código JavaScript para enviar la solicitud POST al hacer clic en el botón
document.getElementById('shutdownButton').addEventListener('click', function() {
fetch('/shutdown', {
method: 'POST'
})
.then(response => response.text())
.then(message => {
console.log(message);
alert('El sistema se está apagando. Por favor, espere unos momentos antes de apagar físicamente.');
})
.catch(error => {
console.error('Error al enviar la solicitud de apagado:', error);
alert('Hubo un error al apagar el sistema.');
});
});
</script>
Again, thanks for all!
GASPOPI
The text was updated successfully, but these errors were encountered:
@Berny23 thanks for a great job with this.
If you allow me a suggestion, could you add a button to shutdown the toypad machine (debian)?
I try with this code and work for me:
Change in /index.js
// ---------------------Begin of shutdown----------------------------------------------------
// Importa el módulo 'child_process' para ejecutar comandos del sistema
const { exec } = require('child_process');
// ...
// Ruta para apagar el sistema
app.post('/shutdown', (request, response) => {
// Ejecuta el comando para apagar el sistema
exec('sudo shutdown -h now', (error, stdout, stderr) => {
if (error) {
console.error(
Error al apagar el sistema: ${error.message}
);response.status(500).send('Error al apagar el sistema');
return;
}
console.log(
Sistema apagado: ${stdout}
);response.send('El sistema se está apagando...');
});
});
// ---------------------End of shutdown----------------------------------------------------
Change in /server/index.html
Apagar el sistema
<style> #shutdownButton { background-color: red; color: white; animation: blink 1s infinite; } @Keyframes blink { 0% { opacity: 0; } 50% { opacity: 1; } 100% { opacity: 0; } } </style> <script> // Agrega el código JavaScript para enviar la solicitud POST al hacer clic en el botón document.getElementById('shutdownButton').addEventListener('click', function() { fetch('/shutdown', { method: 'POST' }) .then(response => response.text()) .then(message => { console.log(message); alert('El sistema se está apagando. Por favor, espere unos momentos antes de apagar físicamente.'); }) .catch(error => { console.error('Error al enviar la solicitud de apagado:', error); alert('Hubo un error al apagar el sistema.'); }); }); </script>Again, thanks for all!
GASPOPI
The text was updated successfully, but these errors were encountered: