Info::IA:création de websites
De wiki_pcwiki2
KEYWORDS: IA, CREATION, WEBSITE
Le 14/07/2025: J'ai découvert que huggingface.co permet (entre autres) de créer des petits sites internet, rien qu'en décrivant le besoin. Exemple: https://huggingface.co/spaces/enzostvs/deepsite Crée moi un site pour gérer deux interrupteurs ethernet:
![]() |
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Contrôle Interrupteurs Ethernet</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
.switch-container {
perspective: 1000px;
}
.switch-btn {
transition: all 0.3s ease, transform 0.2s ease;
transform-style: preserve-3d;
}
.switch-btn:active {
transform: scale(0.95) rotateX(10deg);
}
.switch-btn.on {
box-shadow: 0 0 20px rgba(72, 187, 120, 0.6);
}
.switch-btn.off {
box-shadow: 0 0 20px rgba(239, 68, 68, 0.4);
}
.status-indicator {
width: 12px;
height: 12px;
transition: all 0.3s ease;
}
.connection-status {
animation: pulse 2s infinite;
}
@keyframes pulse {
0% { opacity: 1; }
50% { opacity: 0.5; }
100% { opacity: 1; }
}
</style>
</head>
<body class="bg-gray-100 min-h-screen font-sans">
<div class="container mx-auto px-4 py-8">
<!-- Header -->
<header class="mb-10 text-center">
<h1 class="text-4xl font-bold text-gray-800 mb-2">Contrôle Interrupteurs Ethernet</h1>
<p class="text-gray-600">Interface de contrôle à distance pour vos appareils connectés</p>
<div class="mt-4 flex items-center justify-center space-x-2">
<span id="connectionStatus" class="connection-status inline-block status-indicator rounded-full bg-green-500"></span>
<span id="connectionText" class="text-sm text-gray-600">Connecté</span>
</div>
</header>
<!-- Main Content -->
<main>
<div class="grid grid-cols-1 md:grid-cols-2 gap-8 max-w-4xl mx-auto">
<!-- Switch 1 -->
<div class="bg-white rounded-xl shadow-lg overflow-hidden transition-all hover:shadow-xl">
<div class="p-6">
<div class="flex items-center justify-between mb-4">
<h2 class="text-xl font-semibold text-gray-800">Interrupteur #1</h2>
<div class="flex items-center">
<span id="switch1Status" class="status-indicator rounded-full bg-red-500 mr-2"></span>
<span id="switch1StatusText" class="text-sm font-medium text-gray-500">Éteint</span>
</div>
</div>
<div class="switch-container mt-6 mb-4">
<button id="switch1Btn" class="switch-btn off w-full py-4 px-6 rounded-lg bg-gradient-to-br from-gray-200 to-gray-300 text-gray-700 font-bold text-lg flex items-center justify-center">
<i class="fas fa-power-off mr-2"></i>
<span>Éteint</span>
</button>
</div>
<div class="mt-6">
<h3 class="text-sm font-medium text-gray-500 mb-2">Statistiques</h3>
<div class="grid grid-cols-2 gap-4 text-sm">
<div class="bg-gray-50 p-3 rounded-lg">
<p class="text-gray-500">Dernière activation</p>
<p id="switch1LastOn" class="font-medium">--:--</p>
</div>
<div class="bg-gray-50 p-3 rounded-lg">
<p class="text-gray-500">Dernière désactivation</p>
<p id="switch1LastOff" class="font-medium">--:--</p>
</div>
</div>
</div>
</div>
</div>
<!-- Switch 2 -->
<div class="bg-white rounded-xl shadow-lg overflow-hidden transition-all hover:shadow-xl">
<div class="p-6">
<div class="flex items-center justify-between mb-4">
<h2 class="text-xl font-semibold text-gray-800">Interrupteur #2</h2>
<div class="flex items-center">
<span id="switch2Status" class="status-indicator rounded-full bg-red-500 mr-2"></span>
<span id="switch2StatusText" class="text-sm font-medium text-gray-500">Éteint</span>
</div>
</div>
<div class="switch-container mt-6 mb-4">
<button id="switch2Btn" class="switch-btn off w-full py-4 px-6 rounded-lg bg-gradient-to-br from-gray-200 to-gray-300 text-gray-700 font-bold text-lg flex items-center justify-center">
<i class="fas fa-power-off mr-2"></i>
<span>Éteint</span>
</button>
</div>
<div class="mt-6">
<h3 class="text-sm font-medium text-gray-500 mb-2">Statistiques</h3>
<div class="grid grid-cols-2 gap-4 text-sm">
<div class="bg-gray-50 p-3 rounded-lg">
<p class="text-gray-500">Dernière activation</p>
<p id="switch2LastOn" class="font-medium">--:--</p>
</div>
<div class="bg-gray-50 p-3 rounded-lg">
<p class="text-gray-500">Dernière désactivation</p>
<p id="switch2LastOff" class="font-medium">--:--</p>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Control Both -->
<div class="max-w-4xl mx-auto mt-8 bg-white rounded-xl shadow-lg overflow-hidden">
<div class="p-6">
<h2 class="text-xl font-semibold text-gray-800 mb-4">Contrôle global</h2>
<div class="grid grid-cols-2 md:grid-cols-4 gap-4">
<button id="allOnBtn" class="py-3 px-4 bg-green-500 hover:bg-green-600 text-white rounded-lg font-medium flex items-center justify-center transition">
<i class="fas fa-power-off mr-2 transform rotate-90"></i>
Tout allumer
</button>
<button id="allOffBtn" class="py-3 px-4 bg-red-500 hover:bg-red-600 text-white rounded-lg font-medium flex items-center justify-center transition">
<i class="fas fa-power-off mr-2"></i>
Tout éteindre
</button>
<button id="toggleAllBtn" class="py-3 px-4 bg-blue-500 hover:bg-blue-600 text-white rounded-lg font-medium flex items-center justify-center transition">
<i class="fas fa-random mr-2"></i>
Basculer tout
</button>
<button id="refreshBtn" class="py-3 px-4 bg-gray-500 hover:bg-gray-600 text-white rounded-lg font-medium flex items-center justify-center transition">
<i class="fas fa-sync-alt mr-2"></i>
Actualiser
</button>
</div>
</div>
</div>
</main>
<!-- Footer -->
<footer class="mt-16 text-center text-gray-500 text-sm">
<p>© 2023 Contrôle Interrupteurs Ethernet. Tous droits réservés.</p>
<p class="mt-1">Statut du serveur: <span id="serverStatus" class="font-medium text-green-500">En ligne</span></p>
</footer>
</div>
<script>
// État des interrupteurs
let switch1State = false;
let switch2State = false;
let connectionActive = true;
// Éléments DOM
const switch1Btn = document.getElementById('switch1Btn');
const switch2Btn = document.getElementById('switch2Btn');
const switch1Status = document.getElementById('switch1Status');
const switch2Status = document.getElementById('switch2Status');
const switch1StatusText = document.getElementById('switch1StatusText');
const switch2StatusText = document.getElementById('switch2StatusText');
const switch1LastOn = document.getElementById('switch1LastOn');
const switch1LastOff = document.getElementById('switch1LastOff');
const switch2LastOn = document.getElementById('switch2LastOn');
const switch2LastOff = document.getElementById('switch2LastOff');
const allOnBtn = document.getElementById('allOnBtn');
const allOffBtn = document.getElementById('allOffBtn');
const toggleAllBtn = document.getElementById('toggleAllBtn');
const refreshBtn = document.getElementById('refreshBtn');
const connectionStatus = document.getElementById('connectionStatus');
const connectionText = document.getElementById('connectionText');
const serverStatus = document.getElementById('serverStatus');
// Fonction pour mettre à jour l'état d'un interrupteur
function updateSwitch(switchNum, state) {
const btn = switchNum === 1 ? switch1Btn : switch2Btn;
const status = switchNum === 1 ? switch1Status : switch2Status;
const statusText = switchNum === 1 ? switch1StatusText : switch2StatusText;
const lastOn = switchNum === 1 ? switch1LastOn : switch2LastOn;
const lastOff = switchNum === 1 ? switch1LastOff : switch2LastOff;
if (state) {
// Allumé
btn.classList.remove('off', 'bg-gradient-to-br', 'from-gray-200', 'to-gray-300');
btn.classList.add('on', 'bg-gradient-to-br', 'from-green-200', 'to-green-400', 'text-green-800');
btn.innerHTML = '<i class="fas fa-power-off mr-2"></i><span>Allumé</span>';
status.classList.remove('bg-red-500');
status.classList.add('bg-green-500');
statusText.textContent = 'Allumé';
statusText.classList.remove('text-gray-500');
statusText.classList.add('text-green-600');
// Mettre à jour le dernier allumage
const now = new Date();
lastOn.textContent = `${now.getHours()}:${now.getMinutes().toString().padStart(2, '0')}`;
} else {
// Éteint
btn.classList.remove('on', 'bg-gradient-to-br', 'from-green-200', 'to-green-400', 'text-green-800');
btn.classList.add('off', 'bg-gradient-to-br', 'from-gray-200', 'to-gray-300', 'text-gray-700');
btn.innerHTML = '<i class="fas fa-power-off mr-2"></i><span>Éteint</span>';
status.classList.remove('bg-green-500');
status.classList.add('bg-red-500');
statusText.textContent = 'Éteint';
statusText.classList.remove('text-green-600');
statusText.classList.add('text-gray-500');
// Mettre à jour la dernière extinction
const now = new Date();
lastOff.textContent = `${now.getHours()}:${now.getMinutes().toString().padStart(2, '0')}`;
}
}
// Fonction pour simuler la communication avec le serveur
function sendCommand(switchNum, command) {
return new Promise((resolve) => {
// Simuler un délai réseau
setTimeout(() => {
// Simuler une chance de 10% d'échec de connexion
if (Math.random() < 0.1) {
connectionActive = false;
updateConnectionStatus();
resolve({ success: false, message: "Erreur de connexion" });
} else {
connectionActive = true;
updateConnectionStatus();
// Mettre à jour l'état local
if (switchNum === 'all') {
if (command === 'on') {
switch1State = true;
switch2State = true;
} else if (command === 'off') {
switch1State = false;
switch2State = false;
} else if (command === 'toggle') {
switch1State = !switch1State;
switch2State = !switch2State;
}
updateSwitch(1, switch1State);
updateSwitch(2, switch2State);
} else {
if (command === 'toggle') {
if (switchNum === 1) switch1State = !switch1State;
else switch2State = !switch2State;
} else {
if (switchNum === 1) switch1State = command === 'on';
else switch2State = command === 'on';
}
updateSwitch(switchNum, switchNum === 1 ? switch1State : switch2State);
}
resolve({ success: true, message: "Commande exécutée" });
}
}, 300 + Math.random() * 700); // Délai aléatoire entre 300 et 1000ms
});
}
// Fonction pour mettre à jour l'état de la connexion
function updateConnectionStatus() {
if (connectionActive) {
connectionStatus.classList.remove('bg-red-500', 'bg-yellow-500');
connectionStatus.classList.add('bg-green-500');
connectionText.textContent = 'Connecté';
serverStatus.textContent = 'En ligne';
serverStatus.classList.remove('text-red-500', 'text-yellow-500');
serverStatus.classList.add('text-green-500');
} else {
connectionStatus.classList.remove('bg-green-500', 'bg-yellow-500');
connectionStatus.classList.add('bg-red-500');
connectionText.textContent = 'Déconnecté';
serverStatus.textContent = 'Hors ligne';
serverStatus.classList.remove('text-green-500', 'text-yellow-500');
serverStatus.classList.add('text-red-500');
}
}
// Écouteurs d'événements
switch1Btn.addEventListener('click', async () => {
switch1Btn.disabled = true;
const result = await sendCommand(1, 'toggle');
if (result.success) {
// Animation de feedback
switch1Btn.style.transform = 'scale(0.95) rotateX(10deg)';
setTimeout(() => {
switch1Btn.style.transform = '';
}, 200);
} else {
alert(result.message);
}
switch1Btn.disabled = false;
});
switch2Btn.addEventListener('click', async () => {
switch2Btn.disabled = true;
const result = await sendCommand(2, 'toggle');
if (result.success) {
// Animation de feedback
switch2Btn.style.transform = 'scale(0.95) rotateX(10deg)';
setTimeout(() => {
switch2Btn.style.transform = '';
}, 200);
} else {
alert(result.message);
}
switch2Btn.disabled = false;
});
allOnBtn.addEventListener('click', async () => {
allOnBtn.disabled = true;
const result = await sendCommand('all', 'on');
if (!result.success) {
alert(result.message);
}
allOnBtn.disabled = false;
});
allOffBtn.addEventListener('click', async () => {
allOffBtn.disabled = true;
const result = await sendCommand('all', 'off');
if (!result.success) {
alert(result.message);
}
allOffBtn.disabled = false;
});
toggleAllBtn.addEventListener('click', async () => {
toggleAllBtn.disabled = true;
const result = await sendCommand('all', 'toggle');
if (!result.success) {
alert(result.message);
}
toggleAllBtn.disabled = false;
});
refreshBtn.addEventListener('click', () => {
// Simuler un rafraîchissement
refreshBtn.innerHTML = '<i class="fas fa-spinner fa-spin mr-2"></i> Actualisation';
setTimeout(() => {
refreshBtn.innerHTML = '<i class="fas fa-sync-alt mr-2"></i> Actualiser';
// Simuler une mise à jour de l'état
if (Math.random() < 0.2) {
connectionActive = !connectionActive;
updateConnectionStatus();
}
}, 1000);
});
// Initialisation
updateSwitch(1, switch1State);
updateSwitch(2, switch2State);
updateConnectionStatus();
// Simuler des changements aléatoires d'état (pour la démo)
setInterval(() => {
if (Math.random() < 0.01 && connectionActive) { // 1% de chance de changement
const switchNum = Math.random() < 0.5 ? 1 : 2;
sendCommand(switchNum, 'toggle');
}
}, 5000);
</script>
</body>
</html>
