Docfile commited on
Commit
36c0260
·
verified ·
1 Parent(s): 0510168

Delete templates/index.html

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