Docfile commited on
Commit
1ed404c
·
verified ·
1 Parent(s): 30a627a

Delete templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +0 -387
templates/index.html DELETED
@@ -1,387 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="fr">
3
- <head>
4
- <meta charset="UTF-8">
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>Mariam M-0 | Solution Mathématique</title>
7
- <!-- Tailwind CSS (version 2.2.19 utilisée ici, à mettre à jour si besoin) -->
8
- <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/tailwind.min.css" rel="stylesheet">
9
-
10
- <!-- Configuration optimisée de MathJax avec support étendu LaTeX -->
11
- <script>
12
- window.MathJax = {
13
- tex: {
14
- inlineMath: [['$', '$']],
15
- displayMath: [['$$', '$$']],
16
- processEscapes: true,
17
- // Ajout de la macro pour \boxed
18
- macros: {
19
- boxed: ['\\fbox{#1}', 1]
20
- },
21
- packages: {'[+]': ['autoload','ams']}
22
- },
23
- options: {
24
- enableMenu: false,
25
- messageStyle: 'none'
26
- },
27
- startup: {
28
- pageReady: () => {
29
- console.log('MathJax est complètement chargé.');
30
- window.mathJaxReady = true;
31
- }
32
- }
33
- };
34
- </script>
35
- <script src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js" id="MathJax-script" async></script>
36
- <script src="https://cdn.jsdelivr.net/npm/marked/lib/marked.umd.min.js"></script>
37
-
38
- <style>
39
- @import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;700&display=swap');
40
-
41
- body {
42
- font-family: 'Space Grotesk', sans-serif;
43
- }
44
-
45
- .uploadArea {
46
- background: #f3f4f6;
47
- border: 2px dashed #d1d5db;
48
- transition: border-color 0.2s ease;
49
- }
50
- .uploadArea:hover {
51
- border-color: #3b82f6;
52
- }
53
-
54
- .blue-button {
55
- background: #3b82f6;
56
- transition: background-color 0.2s ease;
57
- }
58
- .blue-button:hover {
59
- background: #2563eb;
60
- }
61
-
62
- .loader {
63
- width: 48px;
64
- height: 48px;
65
- border: 3px solid #3b82f6;
66
- border-bottom-color: transparent;
67
- border-radius: 50%;
68
- display: inline-block;
69
- animation: rotation 1s linear infinite;
70
- }
71
- @keyframes rotation {
72
- 0% { transform: rotate(0deg); }
73
- 100% { transform: rotate(360deg); }
74
- }
75
-
76
- .thought-box {
77
- transition: max-height 0.3s ease-out;
78
- max-height: 0;
79
- overflow: hidden;
80
- }
81
- .thought-box.open {
82
- max-height: 500px;
83
- }
84
-
85
- #thoughtsContent, #answerContent {
86
- max-height: 500px;
87
- overflow-y: auto;
88
- scroll-behavior: smooth;
89
- white-space: pre-wrap;
90
- }
91
-
92
- .preview-image {
93
- max-width: 300px;
94
- max-height: 300px;
95
- object-fit: contain;
96
- }
97
-
98
- .timestamp {
99
- color: #3b82f6;
100
- font-size: 0.9em;
101
- margin-left: 8px;
102
- }
103
-
104
- /* Styles supplémentaires pour une meilleure présentation des tableaux */
105
- table {
106
- border-collapse: collapse;
107
- width: 100%;
108
- margin-bottom: 1rem;
109
- }
110
- th, td {
111
- border: 1px solid #d1d5db;
112
- padding: 0.5rem;
113
- text-align: left;
114
- }
115
- th {
116
- background-color: #f3f4f6;
117
- font-weight: 600;
118
- }
119
- /* Pour un rendu responsive, ajouter éventuellement : */
120
- .table-responsive {
121
- overflow-x: auto;
122
- }
123
- </style>
124
- </head>
125
- <body class="p-4">
126
- <div class="max-w-4xl mx-auto">
127
- <header class="p-6 text-center mb-8">
128
- <h1 class="text-4xl font-bold text-blue-600">Mariam M-0</h1>
129
- <p class="text-gray-600">Solution Mathématique/Physique/Chimie Intelligente</p>
130
- </header>
131
-
132
- <main>
133
- <form id="problemForm" class="space-y-6" novalidate>
134
- <!-- Zone de dépôt et sélection d'image -->
135
- <div class="uploadArea p-8 text-center relative" aria-label="Zone de dépôt d'image">
136
- <input type="file" id="imageInput" accept="image/*" class="absolute inset-0 w-full h-full opacity-0 cursor-pointer" aria-label="Choisir une image">
137
- <div class="space-y-3">
138
- <div class="w-16 h-16 mx-auto border-2 border-blue-400 rounded-full flex items-center justify-center">
139
- <svg class="w-8 h-8 text-blue-400" fill="none" stroke="currentColor" viewBox="0 0 24 24" aria-hidden="true">
140
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
141
- d="M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z" />
142
- </svg>
143
- </div>
144
- <p class="text-gray-700 font-medium">Déposez votre image ici</p>
145
- <p class="text-gray-500 text-sm">ou cliquez pour sélectionner</p>
146
- </div>
147
- </div>
148
-
149
- <!-- Aperçu de l'image -->
150
- <div id="imagePreview" class="hidden text-center">
151
- <img id="previewImage" class="preview-image mx-auto" alt="Prévisualisation de l'image sélectionnée">
152
- </div>
153
-
154
- <button type="submit" class="blue-button w-full py-3 text-white font-medium rounded-lg">
155
- Résoudre le problème
156
- </button>
157
- </form>
158
-
159
- <!-- Loader d'analyse -->
160
- <div id="loader" class="hidden mt-8 text-center">
161
- <span class="loader"></span>
162
- <p class="mt-4 text-gray-600">Analyse en cours...</p>
163
- </div>
164
-
165
- <!-- Affichage de la solution -->
166
- <section id="solution" class="hidden mt-8 space-y-6">
167
- <div class="border-t pt-4">
168
- <button id="thoughtsToggle" type="button" class="w-full flex justify-between items-center p-2">
169
- <span class="font-medium text-gray-700">Processus de Réflexion</span>
170
- <span id="timestamp" class="timestamp"></span>
171
- </button>
172
- <div id="thoughtsBox" class="thought-box">
173
- <div id="thoughtsContent" class="p-4 text-gray-600"></div>
174
- </div>
175
- </div>
176
- <div class="border-t pt-6">
177
- <h3 class="text-xl font-bold text-gray-800 mb-4">Solution</h3>
178
- <!-- Enveloppement d'éventuels tableaux dans une div responsive -->
179
- <div id="answerContent" class="text-gray-700 table-responsive"></div>
180
- </div>
181
- </section>
182
- </main>
183
- </div>
184
-
185
- <script>
186
- document.addEventListener('DOMContentLoaded', () => {
187
- // Récupération des éléments DOM
188
- const form = document.getElementById('problemForm');
189
- const imageInput = document.getElementById('imageInput');
190
- const loader = document.getElementById('loader');
191
- const solutionSection = document.getElementById('solution');
192
- const thoughtsContent = document.getElementById('thoughtsContent');
193
- const answerContent = document.getElementById('answerContent');
194
- const thoughtsToggle = document.getElementById('thoughtsToggle');
195
- const thoughtsBox = document.getElementById('thoughtsBox');
196
- const imagePreview = document.getElementById('imagePreview');
197
- const previewImage = document.getElementById('previewImage');
198
- const timestamp = document.getElementById('timestamp');
199
-
200
- let startTime = null;
201
- let timerInterval = null;
202
- let thoughtsBuffer = '';
203
- let answerBuffer = '';
204
- let currentMode = null;
205
- let updateTimeout = null; // Variable pour le debounce des mises à jour
206
-
207
- // Mise à jour de l'affichage du temps écoulé
208
- const updateTimestamp = () => {
209
- if (startTime) {
210
- const seconds = Math.floor((Date.now() - startTime) / 1000);
211
- timestamp.textContent = `${seconds}s`;
212
- }
213
- };
214
-
215
- const startTimer = () => {
216
- startTime = Date.now();
217
- timerInterval = setInterval(updateTimestamp, 1000);
218
- updateTimestamp();
219
- };
220
-
221
- const stopTimer = () => {
222
- clearInterval(timerInterval);
223
- startTime = null;
224
- timestamp.textContent = '';
225
- };
226
-
227
- // Gestion de la sélection ou du dépôt de l'image
228
- const handleFileSelect = file => {
229
- if (!file) return;
230
- const reader = new FileReader();
231
- reader.onload = e => {
232
- previewImage.src = e.target.result;
233
- imagePreview.classList.remove('hidden');
234
- };
235
- reader.readAsDataURL(file);
236
- };
237
-
238
- // Toggle pour afficher/cacher le processus de réflexion
239
- thoughtsToggle.addEventListener('click', () => {
240
- thoughtsBox.classList.toggle('open');
241
- });
242
-
243
- imageInput.addEventListener('change', e => handleFileSelect(e.target.files[0]));
244
-
245
- // Gestion des événements de glisser-déposer
246
- const dropZone = document.querySelector('.uploadArea');
247
- dropZone.addEventListener('dragover', e => {
248
- e.preventDefault();
249
- dropZone.classList.add('border-blue-400');
250
- });
251
- dropZone.addEventListener('dragleave', e => {
252
- e.preventDefault();
253
- dropZone.classList.remove('border-blue-400');
254
- });
255
- dropZone.addEventListener('drop', e => {
256
- e.preventDefault();
257
- dropZone.classList.remove('border-blue-400');
258
- handleFileSelect(e.dataTransfer.files[0]);
259
- });
260
-
261
- // Fonction pour relancer le rendu MathJax dès que le contenu de la réponse est mis à jour
262
- const typesetAnswerIfReady = async () => {
263
- if (window.mathJaxReady) {
264
- MathJax.startup.document.elements = [document.getElementById('answerContent')];
265
- await MathJax.typesetPromise();
266
- answerContent.scrollTop = answerContent.scrollHeight;
267
- } else {
268
- setTimeout(typesetAnswerIfReady, 200);
269
- }
270
- };
271
-
272
- // Fonction pour déclencher la mise à jour de l'affichage
273
- const updateDisplay = async () => {
274
- // Mise à jour du contenu via marked
275
- thoughtsContent.innerHTML = marked.parse(thoughtsBuffer);
276
- answerContent.innerHTML = marked.parse(answerBuffer);
277
-
278
- // Lancer le rendu MathJax
279
- await typesetAnswerIfReady();
280
- updateTimeout = null;
281
- };
282
-
283
- // Fonction pour planifier la mise à jour (dé-bounce)
284
- const scheduleUpdate = () => {
285
- if (updateTimeout) return;
286
- updateTimeout = setTimeout(updateDisplay, 200);
287
- };
288
-
289
- // Configuration de marked avec support du mode GFM (pour les tableaux) et interprétation des sauts de ligne
290
- marked.setOptions({
291
- gfm: true,
292
- breaks: true
293
- });
294
-
295
- // Soumission du formulaire
296
- form.addEventListener('submit', async e => {
297
- e.preventDefault();
298
- const file = imageInput.files[0];
299
- if (!file) {
300
- alert('Veuillez sélectionner une image.');
301
- return;
302
- }
303
-
304
- // Initialisation de l'affichage et des variables
305
- startTimer();
306
- loader.classList.remove('hidden');
307
- solutionSection.classList.add('hidden');
308
- thoughtsContent.innerHTML = '';
309
- answerContent.innerHTML = '';
310
- thoughtsBuffer = '';
311
- answerBuffer = '';
312
- currentMode = null;
313
- thoughtsBox.classList.add('open');
314
-
315
- const formData = new FormData();
316
- formData.append('image', file);
317
-
318
- try {
319
- // Envoi de la requête au serveur
320
- const response = await fetch('/solve', {
321
- method: 'POST',
322
- body: formData
323
- });
324
-
325
- const reader = response.body.getReader();
326
- const decoder = new TextDecoder();
327
- let buffer = '';
328
-
329
- // Traitement d'un chunk de données
330
- const processChunk = async chunk => {
331
- buffer += decoder.decode(chunk, { stream: true });
332
- const lines = buffer.split('\n\n');
333
- buffer = lines.pop(); // Conserver la dernière ligne incomplète
334
-
335
- for (const line of lines) {
336
- if (!line.startsWith('data:')) continue;
337
- const data = JSON.parse(line.slice(5));
338
-
339
- if (data.mode) {
340
- currentMode = data.mode;
341
- loader.classList.add('hidden');
342
- solutionSection.classList.remove('hidden');
343
- }
344
- if (data.content) {
345
- if (currentMode === 'thinking') {
346
- thoughtsBuffer += data.content;
347
- } else if (currentMode === 'answering') {
348
- answerBuffer += data.content;
349
- }
350
- }
351
- }
352
- // Planifier la mise à jour dé-bouncée
353
- scheduleUpdate();
354
- };
355
-
356
- // Lecture du flux de réponse
357
- while (true) {
358
- const { done, value } = await reader.read();
359
- if (done) {
360
- // Traitement du contenu restant dans le buffer
361
- if (buffer) {
362
- const data = JSON.parse(buffer.slice(5));
363
- if (data.content) {
364
- if (currentMode === 'thinking') {
365
- thoughtsBuffer += data.content;
366
- } else if (currentMode === 'answering') {
367
- answerBuffer += data.content;
368
- }
369
- }
370
- }
371
- scheduleUpdate();
372
- break;
373
- }
374
- await processChunk(value);
375
- }
376
- stopTimer();
377
- } catch (error) {
378
- console.error('Erreur:', error);
379
- alert('Une erreur est survenue.');
380
- loader.classList.add('hidden');
381
- stopTimer();
382
- }
383
- });
384
- });
385
- </script>
386
- </body>
387
- </html>