File size: 14,006 Bytes
09130d3 f9aefa0 f94e218 352039a f94e218 09130d3 f94e218 09130d3 f94e218 09130d3 f94e218 09130d3 f94e218 09130d3 f94e218 352039a 09130d3 f94e218 09130d3 f94e218 09130d3 f94e218 09130d3 f94e218 352039a f94e218 09130d3 f94e218 352039a f94e218 352039a 09130d3 f94e218 352039a f94e218 352039a f94e218 09130d3 352039a f94e218 352039a f94e218 09130d3 f94e218 09130d3 f94e218 09130d3 f94e218 09130d3 f94e218 09130d3 f94e218 09130d3 f94e218 09130d3 f94e218 09130d3 f94e218 352039a f94e218 352039a f94e218 09130d3 f94e218 09130d3 f94e218 352039a 09130d3 f94e218 09130d3 f94e218 09130d3 f94e218 09130d3 f94e218 09130d3 f94e218 09130d3 352039a f9aefa0 352039a f94e218 09130d3 f94e218 09130d3 f94e218 09130d3 f94e218 09130d3 f94e218 09130d3 f94e218 09130d3 f9aefa0 09130d3 f9aefa0 f94e218 09130d3 f94e218 09130d3 f94e218 09130d3 f94e218 09130d3 f94e218 09130d3 f94e218 09130d3 f94e218 09130d3 f94e218 09130d3 f94e218 f9aefa0 f94e218 f9aefa0 f94e218 09130d3 f94e218 0d104ce f94e218 352039a f9aefa0 |
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 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 |
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Résolveur Mathématique IA</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.7.5/socket.io.min.js"></script>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
<style>
/* --- Reset & Variables --- */
:root {
--bg-color: #f4f7fa;
--main-color: #ffffff;
--primary-color: #3b82f6;
--primary-hover: #2563eb;
--text-color: #1f2937;
--text-light: #6b7280;
--border-color: #e5e7eb;
--dark-bg: #111827;
--success-color: #10b981;
--warning-color: #f59e0b;
--error-color: #ef4444;
--shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
--border-radius: 0.75rem;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Inter', sans-serif;
background-color: var(--bg-color);
color: var(--text-color);
line-height: 1.6;
padding: 2rem;
}
/* --- Layout & Main Container --- */
.container {
max-width: 1200px;
margin: 0 auto;
background-color: var(--main-color);
border-radius: var(--border-radius);
box-shadow: var(--shadow);
overflow: hidden;
}
/* --- Header --- */
.header {
padding: 2.5rem;
text-align: center;
border-bottom: 1px solid var(--border-color);
background: linear-gradient(to top, #ffffff, #f9fafb);
}
.header h1 {
font-size: 2.25rem;
font-weight: 700;
letter-spacing: -0.025em;
color: var(--text-color);
}
.header h1 .icon {
color: var(--primary-color);
}
.header p {
margin-top: 0.5rem;
color: var(--text-light);
font-size: 1.1rem;
max-width: 600px;
margin-left: auto;
margin-right: auto;
}
/* --- Upload Section --- */
.main-content {
padding: 2.5rem;
}
.upload-area {
border: 2px dashed var(--border-color);
border-radius: var(--border-radius);
padding: 3rem;
text-align: center;
background-color: #fcfdff;
transition: all 0.3s ease;
}
.upload-area.dragover {
border-color: var(--primary-color);
background-color: #eff6ff;
}
.upload-icon {
font-size: 3rem;
color: var(--primary-color);
margin-bottom: 1rem;
}
.upload-area p {
color: var(--text-light);
margin-bottom: 1.5rem;
}
/* --- Main Button --- */
.btn {
display: inline-block;
background-color: var(--primary-color);
color: white;
padding: 0.8rem 2rem;
border: none;
border-radius: 9999px; /* pill shape */
font-size: 1rem;
font-weight: 500;
cursor: pointer;
text-decoration: none;
transition: background-color 0.2s ease, transform 0.2s ease;
}
.btn:hover {
background-color: var(--primary-hover);
transform: translateY(-2px);
}
/* --- Results & Logs Section --- */
.results-grid {
margin-top: 2.5rem;
display: grid;
grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
gap: 2rem;
}
.panel {
background-color: #f9fafb;
border: 1px solid var(--border-color);
border-radius: var(--border-radius);
padding: 1.5rem;
}
.panel h3 {
font-size: 1.25rem;
font-weight: 600;
margin-bottom: 1rem;
border-bottom: 1px solid var(--border-color);
padding-bottom: 0.75rem;
}
#extractedText {
white-space: pre-wrap;
word-wrap: break-word;
font-family: 'Courier New', monospace;
background-color: var(--main-color);
padding: 1rem;
border-radius: 0.5rem;
max-height: 450px;
overflow-y: auto;
color: var(--text-light);
}
/* --- Logs --- */
#logContainer {
height: 450px;
overflow-y: auto;
background: var(--dark-bg);
color: #d1d5db;
padding: 1rem;
border-radius: 0.5rem;
font-family: 'Courier New', monospace;
font-size: 0.875rem;
}
.log-entry {
margin-bottom: 0.25rem;
padding: 0.2rem 0.5rem;
border-radius: 3px;
}
.log-timestamp { color: #9ca3af; margin-right: 0.5rem; }
.log-info { color: #3b82f6; }
.log-success { color: #10b981; }
.log-warning { color: #f59e0b; }
.log-error { color: #ef4444; font-weight: bold; }
/* --- Status Bar & Download --- */
#status-section {
padding: 1.5rem 2.5rem;
background-color: #f9fafb;
border-top: 1px solid var(--border-color);
text-align: center;
}
.status-badge {
display: inline-flex;
align-items: center;
gap: 0.5rem;
padding: 0.5rem 1.25rem;
border-radius: 9999px;
font-weight: 500;
}
.status-processing { background-color: #fef3c7; color: #92400e; }
.status-completed { background-color: #d1fae5; color: #065f46; }
.status-failed { background-color: #fee2e2; color: #991b1b; }
#downloadSection {
margin-top: 1rem;
}
.hidden {
display: none;
}
</style>
</head>
<body>
<div class="container">
<header class="header">
<h1><span class="icon">🧮</span> Résolveur Mathématique IA</h1>
<p>Soumettez une image d'un problème mathématique et laissez nos agents IA générer une solution rigoureuse, étape par étape.</p>
</header>
<main class="main-content">
<!-- Section d'upload corrigée -->
<section id="upload-section">
<div class="upload-area" id="uploadArea">
<div class="upload-icon">📄</div>
<p>Glissez-déposez votre image ici, ou cliquez sur le bouton pour la sélectionner.</p>
<!-- Ce bouton est maintenant le point d'interaction principal pour le clic -->
<button type="button" class="btn" id="selectFileBtn">Choisir un fichier</button>
<!-- L'input de fichier est caché et sera activé par le JS -->
<input type="file" id="fileInput" accept="image/*" class="hidden">
</div>
</section>
<!-- Section pour afficher le statut global, cachée au début -->
<section id="status-section" class="hidden">
<div id="statusBadge" class="status-badge"></div>
<div id="downloadSection" class="hidden">
<a href="#" id="downloadBtn" class="btn">📥 Télécharger la solution</a>
</div>
</section>
<!-- Grille pour les résultats, cachée au début -->
<section id="results-grid" class="results-grid hidden">
<div class="panel">
<h3>📝 Texte extrait de l'image</h3>
<div id="extractedText">Le texte de votre image apparaîtra ici...</div>
</div>
<div class="panel">
<h3>📊 Journal de traitement</h3>
<div id="logContainer"></div>
</div>
</section>
</main>
</div>
<script>
const socket = io();
let currentTaskId = null;
// --- DOM Elements ---
const uploadArea = document.getElementById('uploadArea');
const fileInput = document.getElementById('fileInput');
const selectFileBtn = document.getElementById('selectFileBtn');
const statusSection = document.getElementById('status-section');
const statusBadge = document.getElementById('statusBadge');
const resultsGrid = document.getElementById('results-grid');
const extractedTextEl = document.getElementById('extractedText');
const logContainer = document.getElementById('logContainer');
const downloadSection = document.getElementById('downloadSection');
const downloadBtn = document.getElementById('downloadBtn');
// --- Event Listeners ---
// CORRECTION : Le bouton déclenche l'input de fichier
selectFileBtn.addEventListener('click', () => {
fileInput.click();
});
// L'input de fichier, une fois un fichier choisi, lance l'upload
fileInput.addEventListener('change', (e) => {
if (e.target.files.length > 0) {
handleFileUpload(e.target.files[0]);
}
});
// Gestion du glisser-déposer (Drag & Drop)
['dragenter', 'dragover', 'dragleave', 'drop'].forEach(eventName => {
uploadArea.addEventListener(eventName, preventDefaults, false);
});
function preventDefaults(e) {
e.preventDefault();
e.stopPropagation();
}
['dragenter', 'dragover'].forEach(eventName => {
uploadArea.addEventListener(eventName, () => uploadArea.classList.add('dragover'), false);
});
['dragleave', 'drop'].forEach(eventName => {
uploadArea.addEventListener(eventName, () => uploadArea.classList.remove('dragover'), false);
});
uploadArea.addEventListener('drop', (e) => {
const files = e.dataTransfer.files;
if (files.length > 0) {
handleFileUpload(files[0]);
}
});
// --- Core Functions ---
function resetUI() {
statusSection.classList.add('hidden');
resultsGrid.classList.add('hidden');
downloadSection.classList.add('hidden');
logContainer.innerHTML = '';
extractedTextEl.textContent = 'Le texte de votre image apparaîtra ici...';
currentTaskId = null;
}
function handleFileUpload(file) {
resetUI();
const formData = new FormData();
formData.append('file', file);
updateStatus('processing', '🚀 Envoi et analyse de l\'image...');
statusSection.classList.remove('hidden');
fetch('/upload', {
method: 'POST',
body: formData
})
.then(response => {
if (!response.ok) {
throw new Error(`Erreur serveur: ${response.statusText}`);
}
return response.json();
})
.then(data => {
if (data.error) {
throw new Error(data.error);
}
currentTaskId = data.task_id;
extractedTextEl.textContent = data.extracted_text;
resultsGrid.classList.remove('hidden');
updateStatus('processing', '🧠 Résolution en cours...');
})
.catch(error => {
updateStatus('failed', `❌ Erreur critique : ${error.message}`);
console.error('Upload Error:', error);
});
}
function updateStatus(status, message) {
statusBadge.className = `status-badge status-${status}`;
statusBadge.textContent = message;
}
function addLog(timestamp, level, message) {
const logEntry = document.createElement('div');
logEntry.className = `log-entry log-${level}`;
logEntry.innerHTML = `<span class="log-timestamp">[${timestamp}]</span> ${message}`;
logContainer.appendChild(logEntry);
logContainer.scrollTop = logContainer.scrollHeight;
}
// --- WebSocket Event Handlers ---
socket.on('log_update', (data) => {
if (data.task_id === currentTaskId) {
addLog(data.log.timestamp, data.log.level, data.log.message);
}
});
socket.on('task_completed', (data) => {
if (data.task_id === currentTaskId) {
updateStatus('completed', '✅ Solution générée avec succès !');
downloadSection.classList.remove('hidden');
downloadBtn.href = `/download/${currentTaskId}`;
}
});
socket.on('task_failed', (data) => {
if (data.task_id === currentTaskId) {
updateStatus('failed', '⚠️ Échec de la résolution (solution partielle disponible)');
downloadSection.classList.remove('hidden');
downloadBtn.href = `/download/${currentTaskId}`;
}
});
socket.on('task_error', (data) => {
if (data.task_id === currentTaskId) {
updateStatus('failed', `❌ Erreur système: ${data.error}`);
}
});
</script>
</body>
</html> |