Spaces:
Running
Running
File size: 24,316 Bytes
9468c91 2abfdf4 078c480 2abfdf4 078c480 2abfdf4 078c480 2abfdf4 078c480 2abfdf4 078c480 2abfdf4 078c480 2abfdf4 078c480 2abfdf4 078c480 2abfdf4 078c480 2abfdf4 078c480 2abfdf4 078c480 2abfdf4 078c480 2abfdf4 078c480 2abfdf4 078c480 2abfdf4 078c480 2abfdf4 078c480 2abfdf4 078c480 2abfdf4 078c480 2abfdf4 078c480 2abfdf4 078c480 2abfdf4 078c480 2abfdf4 078c480 2abfdf4 078c480 2abfdf4 078c480 2abfdf4 078c480 2abfdf4 078c480 2abfdf4 078c480 2abfdf4 078c480 2abfdf4 078c480 2abfdf4 078c480 2abfdf4 078c480 2abfdf4 9468c91 2abfdf4 078c480 2abfdf4 078c480 2abfdf4 078c480 2abfdf4 078c480 2abfdf4 078c480 2abfdf4 9468c91 078c480 2abfdf4 9468c91 078c480 2abfdf4 078c480 2abfdf4 078c480 2abfdf4 078c480 2abfdf4 078c480 2abfdf4 9468c91 078c480 2abfdf4 078c480 9468c91 078c480 2abfdf4 078c480 2abfdf4 078c480 2abfdf4 078c480 2abfdf4 078c480 2abfdf4 078c480 2abfdf4 078c480 2abfdf4 078c480 2abfdf4 078c480 2abfdf4 078c480 2abfdf4 |
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 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 |
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Résolveur d'exercices</title>
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css" rel="stylesheet">
<link href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css" rel="stylesheet">
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/3.2.0/es5/tex-mml-chtml.js"></script>
<style>
:root {
--primary-color: #4361ee;
--secondary-color: #3f37c9;
--accent-color: #f72585;
--text-color: #333;
--light-color: #f8f9fa;
--dark-color: #212529;
--success-color: #4cc9a0;
--border-radius: 8px;
--box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
--transition: all 0.3s ease;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background: linear-gradient(135deg, #f5f7fa 0%, #e4e8f0 100%);
color: var(--text-color);
line-height: 1.6;
min-height: 100vh;
padding: 20px;
}
header {
text-align: center;
margin-bottom: 2rem;
animation: fadeIn 1s;
}
h1 {
color: var(--primary-color);
font-size: 2.2rem;
margin-bottom: 0.5rem;
}
.subheading {
color: var(--secondary-color);
font-size: 1.1rem;
font-weight: 500;
}
.container {
max-width: 800px;
margin: 0 auto;
background-color: white;
border-radius: var(--border-radius);
box-shadow: var(--box-shadow);
overflow: hidden;
}
.tabs {
display: flex;
background-color: var(--light-color);
border-bottom: 1px solid #e1e5ea;
}
.tab {
flex: 1;
padding: 15px;
text-align: center;
cursor: pointer;
transition: var(--transition);
font-weight: 600;
color: var(--text-color);
position: relative;
overflow: hidden;
}
.tab.active {
background-color: white;
color: var(--primary-color);
}
.tab:after {
content: '';
position: absolute;
bottom: 0;
left: 0;
width: 100%;
height: 3px;
background-color: var(--primary-color);
transform: scaleX(0);
transition: transform 0.3s ease;
}
.tab.active:after {
transform: scaleX(1);
}
.tab-content {
padding: 30px;
display: none;
}
.tab-content.active {
display: block;
animation: fadeIn 0.5s;
}
.upload-container {
text-align: center;
padding: 20px;
border: 2px dashed #d1d5db;
border-radius: var(--border-radius);
margin-bottom: 20px;
transition: var(--transition);
cursor: pointer;
}
.upload-container:hover {
border-color: var(--primary-color);
background-color: rgba(67, 97, 238, 0.05);
}
.upload-icon {
font-size: 3rem;
color: var(--primary-color);
margin-bottom: 15px;
}
.upload-text {
margin-bottom: 15px;
font-size: 1.1rem;
}
.upload-input {
display: none;
}
.btn {
display: inline-block;
background-color: var(--primary-color);
color: white;
padding: 12px 25px;
border: none;
border-radius: var(--border-radius);
cursor: pointer;
font-size: 1rem;
font-weight: 600;
transition: var(--transition);
text-align: center;
text-decoration: none;
margin: 10px 0;
}
.btn:hover {
background-color: var(--secondary-color);
transform: translateY(-2px);
box-shadow: 0 5px 15px rgba(67, 97, 238, 0.3);
}
.btn-full {
width: 100%;
}
.btn-secondary {
background-color: var(--light-color);
color: var(--text-color);
}
.btn-secondary:hover {
background-color: #e2e6ea;
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}
.btn-accent {
background-color: var(--accent-color);
}
.btn-accent:hover {
background-color: #e5147a;
box-shadow: 0 5px 15px rgba(247, 37, 133, 0.3);
}
.image-preview {
max-width: 100%;
height: auto;
margin: 20px 0;
border-radius: var(--border-radius);
box-shadow: var(--box-shadow);
display: none;
}
.result-container {
margin-top: 30px;
padding: 20px;
background-color: var(--light-color);
border-radius: var(--border-radius);
display: none;
}
.loading {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 30px;
display: none;
}
.loading-text {
margin-top: 15px;
font-weight: 600;
color: var(--primary-color);
}
.thinking-indicator {
display: inline-block;
margin-left: 10px;
font-size: 1.5rem;
color: var(--primary-color);
animation: pulse 1.5s infinite;
}
@keyframes pulse {
0% { transform: scale(0.95); opacity: 0.7; }
50% { transform: scale(1.05); opacity: 1; }
100% { transform: scale(0.95); opacity: 0.7; }
}
@keyframes fadeIn {
from { opacity: 0; transform: translateY(10px); }
to { opacity: 1; transform: translateY(0); }
}
.features {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: 20px;
margin: 30px 0;
}
.feature {
text-align: center;
padding: 20px;
background-color: white;
border-radius: var(--border-radius);
box-shadow: var(--box-shadow);
transition: var(--transition);
}
.feature:hover {
transform: translateY(-5px);
box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}
.feature-icon {
font-size: 2.5rem;
color: var(--primary-color);
margin-bottom: 15px;
}
.feature-title {
font-size: 1.2rem;
margin-bottom: 10px;
font-weight: 600;
}
.feature-desc {
color: #666;
font-size: 0.95rem;
}
footer {
text-align: center;
margin-top: 3rem;
color: #6c757d;
font-size: 0.9rem;
}
/* Mobile responsive styles */
@media (max-width: 768px) {
body {
padding: 10px;
}
h1 {
font-size: 1.8rem;
}
.subheading {
font-size: 1rem;
}
.container {
border-radius: var(--border-radius);
}
.tab {
padding: 12px 5px;
font-size: 0.9rem;
}
.tab-content {
padding: 20px 15px;
}
.upload-icon {
font-size: 2.5rem;
}
.upload-text {
font-size: 1rem;
}
.btn {
padding: 10px 20px;
font-size: 0.95rem;
}
.features {
grid-template-columns: 1fr;
}
}
</style>
</head>
<body>
<header>
<h1>SolveMath.AI</h1>
<p class="subheading">Résolution avancée d'exercices par Intelligence Artificielle</p>
</header>
<div class="container">
<div class="tabs">
<div class="tab active" data-tab="standard">Standard</div>
<div class="tab" data-tab="pro">Pro (Réflexion)</div>
</div>
<div class="tab-content active" id="standard-content">
<p>Utilisez notre IA standard pour résoudre rapidement vos exercices.</p>
<div class="upload-container" id="standard-upload">
<i class="fas fa-cloud-upload-alt upload-icon"></i>
<p class="upload-text">Cliquez ou déposez une image de votre exercice</p>
<input type="file" id="standard-file" class="upload-input" accept="image/*">
</div>
<img id="standard-preview" class="image-preview">
<button id="standard-solve" class="btn btn-full" disabled>Résoudre l'exercice</button>
<div id="standard-loading" class="loading">
<i class="fas fa-cog fa-spin fa-2x"></i>
<p class="loading-text">Analyse en cours... <span id="standard-thinking-status"></span></p>
</div>
<div id="standard-result" class="result-container">
<h3>Solution :</h3>
<div id="standard-solution"></div>
</div>
</div>
<div class="tab-content" id="pro-content">
<p>Mode Pro : utilise une réflexion approfondie pour résoudre des exercices complexes.</p>
<div class="upload-container" id="pro-upload">
<i class="fas fa-cloud-upload-alt upload-icon"></i>
<p class="upload-text">Cliquez ou déposez une image de votre exercice complexe</p>
<input type="file" id="pro-file" class="upload-input" accept="image/*">
</div>
<img id="pro-preview" class="image-preview">
<button id="pro-solve" class="btn btn-full btn-accent" disabled>Résoudre avec réflexion approfondie</button>
<div id="pro-loading" class="loading">
<i class="fas fa-brain fa-2x"></i>
<p class="loading-text">Analyse approfondie... <span id="pro-thinking-status"></span></p>
</div>
<div id="pro-result" class="result-container">
<h3>Solution détaillée :</h3>
<div id="pro-solution"></div>
</div>
</div>
</div>
<div class="features">
<div class="feature">
<i class="fas fa-bolt feature-icon"></i>
<h3 class="feature-title">Rapide</h3>
<p class="feature-desc">Solutions instantanées pour les exercices simples</p>
</div>
<div class="feature">
<i class="fas fa-brain feature-icon"></i>
<p class="feature-title">Intelligent</p>
<p class="feature-desc">Résolution détaillée de problèmes complexes</p>
</div>
<div class="feature">
<i class="fas fa-mobile-alt feature-icon"></i>
<p class="feature-title">Mobile</p>
<p class="feature-desc">Fonctionne parfaitement sur tous les appareils</p>
</div>
</div>
<footer>
<p>© 2025 SolveMath.AI - Propulsé par l'intelligence artificielle</p>
</footer>
<script>
// Tab switching functionality
const tabs = document.querySelectorAll('.tab');
const tabContents = document.querySelectorAll('.tab-content');
tabs.forEach(tab => {
tab.addEventListener('click', () => {
const tabId = tab.getAttribute('data-tab');
// Update active tab
tabs.forEach(t => t.classList.remove('active'));
tab.classList.add('active');
// Update active content
tabContents.forEach(content => content.classList.remove('active'));
document.getElementById(`${tabId}-content`).classList.add('active');
});
});
// File upload functionality - Standard mode
const standardUpload = document.getElementById('standard-upload');
const standardFile = document.getElementById('standard-file');
const standardPreview = document.getElementById('standard-preview');
const standardSolve = document.getElementById('standard-solve');
const standardLoading = document.getElementById('standard-loading');
const standardResult = document.getElementById('standard-result');
const standardSolution = document.getElementById('standard-solution');
const standardThinkingStatus = document.getElementById('standard-thinking-status');
standardUpload.addEventListener('click', () => standardFile.click());
standardFile.addEventListener('change', (e) => {
if (e.target.files.length > 0) {
const file = e.target.files[0];
const reader = new FileReader();
reader.onload = (e) => {
standardPreview.src = e.target.result;
standardPreview.style.display = 'block';
standardSolve.disabled = false;
};
reader.readAsDataURL(file);
}
});
// File upload functionality - Pro mode
const proUpload = document.getElementById('pro-upload');
const proFile = document.getElementById('pro-file');
const proPreview = document.getElementById('pro-preview');
const proSolve = document.getElementById('pro-solve');
const proLoading = document.getElementById('pro-loading');
const proResult = document.getElementById('pro-result');
const proSolution = document.getElementById('pro-solution');
const proThinkingStatus = document.getElementById('pro-thinking-status');
proUpload.addEventListener('click', () => proFile.click());
proFile.addEventListener('change', (e) => {
if (e.target.files.length > 0) {
const file = e.target.files[0];
const reader = new FileReader();
reader.onload = (e) => {
proPreview.src = e.target.result;
proPreview.style.display = 'block';
proSolve.disabled = false;
};
reader.readAsDataURL(file);
}
});
// Drag and drop functionality
['standard', 'pro'].forEach(mode => {
const uploadContainer = document.getElementById(`${mode}-upload`);
const fileInput = document.getElementById(`${mode}-file`);
const preview = document.getElementById(`${mode}-preview`);
const solveBtn = document.getElementById(`${mode}-solve`);
['dragenter', 'dragover', 'dragleave', 'drop'].forEach(eventName => {
uploadContainer.addEventListener(eventName, preventDefaults, false);
});
function preventDefaults(e) {
e.preventDefault();
e.stopPropagation();
}
['dragenter', 'dragover'].forEach(eventName => {
uploadContainer.addEventListener(eventName, () => {
uploadContainer.classList.add('highlight');
}, false);
});
['dragleave', 'drop'].forEach(eventName => {
uploadContainer.addEventListener(eventName, () => {
uploadContainer.classList.remove('highlight');
}, false);
});
uploadContainer.addEventListener('drop', (e) => {
const file = e.dataTransfer.files[0];
if (file && file.type.startsWith('image/')) {
fileInput.files = e.dataTransfer.files;
const reader = new FileReader();
reader.onload = (e) => {
preview.src = e.target.result;
preview.style.display = 'block';
solveBtn.disabled = false;
};
reader.readAsDataURL(file);
}
}, false);
});
// Solve functionality - Standard
standardSolve.addEventListener('click', () => {
if (!standardFile.files.length) return;
const formData = new FormData();
formData.append('image', standardFile.files[0]);
standardSolve.disabled = true;
standardLoading.style.display = 'flex';
standardResult.style.display = 'none';
standardSolution.innerHTML = '';
const eventSource = new EventSource('/solved?' + new URLSearchParams({
timestamp: new Date().getTime()
}));
let accumulatedText = '';
eventSource.addEventListener('message', function(event) {
const data = JSON.parse(event.data);
if (data.mode === 'thinking') {
standardThinkingStatus.innerHTML = '<span class="thinking-indicator">🤔</span>';
}
if (data.mode === 'answering') {
standardThinkingStatus.innerHTML = '';
}
if (data.content) {
accumulatedText += data.content;
standardSolution.innerHTML = accumulatedText;
standardResult.style.display = 'block';
// Render LaTeX if present
if (typeof MathJax !== 'undefined') {
MathJax.typesetPromise([standardSolution]);
}
}
if (data.error) {
standardSolution.innerHTML = `<p class="error">Erreur: ${data.error}</p>`;
standardResult.style.display = 'block';
eventSource.close();
standardLoading.style.display = 'none';
standardSolve.disabled = false;
}
});
eventSource.addEventListener('error', function() {
eventSource.close();
standardLoading.style.display = 'none';
standardSolve.disabled = false;
if (!accumulatedText) {
standardSolution.innerHTML = '<p class="error">Une erreur est survenue lors de la communication avec le serveur.</p>';
standardResult.style.display = 'block';
}
});
// Actual fetch to backend
fetch('/solved', {
method: 'POST',
body: formData
}).catch(error => {
console.error('Error:', error);
eventSource.close();
standardLoading.style.display = 'none';
standardSolve.disabled = false;
standardSolution.innerHTML = '<p class="error">Une erreur est survenue lors de l\'envoi de l\'image.</p>';
standardResult.style.display = 'block';
});
});
// Solve functionality - Pro
proSolve.addEventListener('click', () => {
if (!proFile.files.length) return;
const formData = new FormData();
formData.append('image', proFile.files[0]);
proSolve.disabled = true;
proLoading.style.display = 'flex';
proResult.style.display = 'none';
proSolution.innerHTML = '';
const eventSource = new EventSource('/solve?' + new URLSearchParams({
timestamp: new Date().getTime()
}));
let accumulatedText = '';
eventSource.addEventListener('message', function(event) {
const data = JSON.parse(event.data);
if (data.mode === 'thinking') {
proThinkingStatus.innerHTML = '<span class="thinking-indicator">💭</span>';
}
if (data.mode === 'answering') {
proThinkingStatus.innerHTML = '';
}
if (data.content) {
accumulatedText += data.content;
proSolution.innerHTML = accumulatedText;
proResult.style.display = 'block';
// Render LaTeX if present
if (typeof MathJax !== 'undefined') {
MathJax.typesetPromise([proSolution]);
}
}
if (data.error) {
proSolution.innerHTML = `<p class="error">Erreur: ${data.error}</p>`;
proResult.style.display = 'block';
eventSource.close();
proLoading.style.display = 'none';
proSolve.disabled = false;
}
});
eventSource.addEventListener('error', function() {
eventSource.close();
proLoading.style.display = 'none';
proSolve.disabled = false;
if (!accumulatedText) {
proSolution.innerHTML = '<p class="error">Une erreur est survenue lors de la communication avec le serveur.</p>';
proResult.style.display = 'block';
}
});
// Actual fetch to backend
fetch('/solve', {
method: 'POST',
body: formData
}).catch(error => {
console.error('Error:', error);
eventSource.close();
proLoading.style.display = 'none';
proSolve.disabled = false;
proSolution.innerHTML = '<p class="error">Une erreur est survenue lors de l\'envoi de l\'image.</p>';
proResult.style.display = 'block';
});
});
// Support for drag and drop highlight styling
document.querySelectorAll('.upload-container').forEach(container => {
container.addEventListener('dragenter', () => {
container.style.borderColor = 'var(--primary-color)';
container.style.backgroundColor = 'rgba(67, 97, 238, 0.05)';
});
container.addEventListener('dragleave', () => {
container.style.borderColor = '#d1d5db';
container.style.backgroundColor = '';
});
});
</script>
</body>
</html> |