Spaces:
Sleeping
Sleeping
File size: 4,108 Bytes
6468adb |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
<!-- templates/index.html -->
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Générateur de Comptes</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/axios/1.6.2/axios.min.js"></script>
<style>
body {
font-family: Arial, sans-serif;
max-width: 800px;
margin: 0 auto;
padding: 20px;
}
.form-group {
margin-bottom: 15px;
}
.btn {
padding: 10px 20px;
background-color: #007bff;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
}
.btn:disabled {
background-color: #ccc;
}
.status {
margin-top: 20px;
padding: 10px;
border-radius: 4px;
}
.error {
background-color: #ffebee;
color: #c62828;
}
.success {
background-color: #e8f5e9;
color: #2e7d32;
}
.progress {
margin-top: 10px;
padding: 10px;
background-color: #f5f5f5;
border-radius: 4px;
display: none;
}
</style>
</head>
<body>
<h1>Générateur de Comptes</h1>
<div class="form-group">
<label for="num_accounts">Nombre de comptes à créer:</label>
<input type="number" id="num_accounts" min="1" value="1" class="form-control">
</div>
<button onclick="createAccounts()" id="submitBtn" class="btn">Générer les comptes</button>
<div id="status" class="status" style="display: none;"></div>
<div id="progress" class="progress">
<div>Création des comptes en cours...</div>
<div>Comptes créés: <span id="accountsCreated">0</span></div>
</div>
<script>
async function createAccounts() {
const numAccounts = document.getElementById('num_accounts').value;
const submitBtn = document.getElementById('submitBtn');
const status = document.getElementById('status');
const progress = document.getElementById('progress');
submitBtn.disabled = true;
status.style.display = 'none';
progress.style.display = 'block';
try {
const response = await axios.post('/create_accounts', {
num_accounts: numAccounts
}, {
headers: {
'Content-Type': 'application/json'
}
});
// Commencer à vérifier le statut
checkStatus();
status.textContent = response.data.message;
status.className = 'status success';
status.style.display = 'block';
} catch (error) {
status.textContent = error.response?.data?.error || 'Une erreur est survenue';
status.className = 'status error';
status.style.display = 'block';
progress.style.display = 'none';
submitBtn.disabled = false;
}
}
async function checkStatus() {
const accountsCreated = document.getElementById('accountsCreated');
try {
const response = await axios.get('/check_status');
if (response.data.status === 'completed') {
document.getElementById('progress').style.display = 'none';
document.getElementById('submitBtn').disabled = false;
return;
}
accountsCreated.textContent = response.data.accounts_created;
setTimeout(checkStatus, 2000);
} catch (error) {
console.error('Erreur lors de la vérification du statut:', error);
}
}
</script>
</body>
</html> |