Docfile commited on
Commit
15e477d
·
verified ·
1 Parent(s): dfc76ba

Delete templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +0 -369
templates/index.html DELETED
@@ -1,369 +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
- <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/tailwind.min.css" rel="stylesheet">
8
- <script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/MathJax.js?config=TeX-AMS_HTML"></script>
9
- <style>
10
- @import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600;700&display=swap');
11
-
12
- body {
13
- font-family: 'Space Grotesk', sans-serif;
14
- background: linear-gradient(125deg, #000428 0%, #004e92 100%);
15
- min-height: 100vh;
16
- }
17
-
18
- .glass-card {
19
- background: rgba(255, 255, 255, 0.05);
20
- backdrop-filter: blur(10px);
21
- border: 1px solid rgba(255, 255, 255, 0.1);
22
- box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
23
- }
24
-
25
- .uploadArea {
26
- background: linear-gradient(145deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0.02) 100%);
27
- border: 2px dashed rgba(255, 255, 255, 0.2);
28
- }
29
-
30
- .uploadArea:hover {
31
- border-color: #60A5FA;
32
- transform: translateY(-2px);
33
- }
34
-
35
- .neon-button {
36
- background: linear-gradient(90deg, #4F46E5 0%, #60A5FA 100%);
37
- box-shadow: 0 0 15px rgba(79, 70, 229, 0.5);
38
- transition: all 0.3s ease;
39
- }
40
-
41
- .neon-button:hover {
42
- box-shadow: 0 0 25px rgba(79, 70, 229, 0.7);
43
- transform: translateY(-2px);
44
- }
45
-
46
- .loader {
47
- width: 48px;
48
- height: 48px;
49
- border: 3px solid #FFF;
50
- border-bottom-color: transparent;
51
- border-radius: 50%;
52
- display: inline-block;
53
- box-sizing: border-box;
54
- animation: rotation 1s linear infinite;
55
- }
56
-
57
- @keyframes rotation {
58
- 0% { transform: rotate(0deg); }
59
- 100% { transform: rotate(360deg); }
60
- }
61
-
62
- .thought-box {
63
- transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
64
- max-height: 0;
65
- overflow: hidden;
66
- }
67
-
68
- .thought-box.open {
69
- max-height: 1000px;
70
- }
71
-
72
- .glow {
73
- animation: glow 2s ease-in-out infinite alternate;
74
- }
75
-
76
- @keyframes glow {
77
- from { text-shadow: 0 0 10px #fff, 0 0 20px #fff, 0 0 30px #60A5FA; }
78
- to { text-shadow: 0 0 20px #fff, 0 0 30px #4F46E5, 0 0 40px #4F46E5; }
79
- }
80
-
81
- .preview-container {
82
- display: flex;
83
- justify-content: center;
84
- align-items: center;
85
- margin-top: 20px;
86
- }
87
-
88
- .preview-image {
89
- max-width: 300px;
90
- max-height: 300px;
91
- border-radius: 8px;
92
- box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
93
- }
94
-
95
- #thoughtsContent, #answerContent {
96
- max-height: 500px;
97
- overflow-y: auto;
98
- }
99
- </style>
100
- </head>
101
- <body class="p-4 md:p-8">
102
- <div class="container mx-auto max-w-4xl">
103
- <div class="glass-card rounded-3xl p-8 md:p-12">
104
- <div class="text-center mb-12">
105
- <h1 class="text-5xl font-bold text-white glow mb-4">Mariam M-0</h1>
106
- <p class="text-blue-200 text-lg">Solution Mathématique Intelligente</p>
107
- </div>
108
-
109
- <form id="problemForm" class="space-y-8" enctype="multipart/form-data">
110
- <div class="relative">
111
- <div class="uploadArea rounded-2xl p-12 text-center transition-all duration-300 cursor-pointer">
112
- <input type="file" id="imageInput" name="image" accept="image/*" class="absolute inset-0 w-full h-full opacity-0 cursor-pointer">
113
- <div class="space-y-4">
114
- <div class="w-20 h-20 mx-auto border-2 border-blue-400 rounded-full flex items-center justify-center">
115
- <svg class="w-10 h-10 text-blue-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
116
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" 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" />
117
- </svg>
118
- </div>
119
- <div class="text-blue-200 text-lg font-medium">Déposez votre image ici</div>
120
- <div class="text-blue-300/60 text-sm">ou cliquez pour sélectionner</div>
121
- </div>
122
- </div>
123
- <div id="imagePreview" class="preview-container hidden">
124
- <img id="previewImage" src="#" alt="Prévisualisation de l'image" class="preview-image">
125
- </div>
126
- </div>
127
-
128
- <button type="submit" class="neon-button w-full py-4 rounded-xl text-white font-medium text-lg transition-all duration-300">
129
- Résoudre le problème
130
- </button>
131
- </form>
132
-
133
- <div id="loader" class="hidden mt-12">
134
- <div class="flex flex-col items-center justify-center space-y-4">
135
- <span class="loader"></span>
136
- <div class="text-blue-200 text-lg">Analyse en cours...</div>
137
- </div>
138
- </div>
139
-
140
- <div id="solution" class="hidden mt-12 space-y-8">
141
- <div class="glass-card rounded-2xl p-6">
142
- <button id="thoughtsToggle" class="w-full flex justify-between items-center text-left text-lg font-medium text-white hover:text-blue-300 transition-colors">
143
- <span>Processus de Réflexion</span>
144
- <svg class="w-6 h-6 transform transition-transform duration-300" fill="none" stroke="currentColor" viewBox="0 0 24 24">
145
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"/>
146
- </svg>
147
- </button>
148
- <div id="thoughtsBox" class="thought-box">
149
- <div id="thoughtsContent" class="prose prose-invert max-w-none text-blue-100 mt-4"></div>
150
- </div>
151
- </div>
152
-
153
- <div class="glass-card rounded-2xl p-8">
154
- <h3 class="text-2xl font-bold text-white mb-6">Solution</h3>
155
- <div id="answerContent" class="prose prose-invert max-w-none text-blue-100"></div>
156
- </div>
157
- </div>
158
- </div>
159
- </div>
160
-
161
- <script>
162
- document.addEventListener('DOMContentLoaded', () => {
163
- // Configuration de MathJax pour un meilleur support LaTeX
164
- window.MathJax = {
165
- tex: {
166
- inlineMath: [['$', '$'], ['\\(', '\\)']],
167
- displayMath: [['$$', '$$'], ['\\[', '\\]']],
168
- processEscapes: true,
169
- processEnvironments: true,
170
- packages: ['base', 'ams', 'noerrors', 'noundefined']
171
- },
172
- options: {
173
- ignoreHtmlClass: 'tex2jax_ignore',
174
- processHtmlClass: 'tex2jax_process'
175
- },
176
- svg: {
177
- fontCache: 'global'
178
- }
179
- };
180
-
181
- const form = document.getElementById('problemForm');
182
- const imageInput = document.getElementById('imageInput');
183
- const loader = document.getElementById('loader');
184
- const solutionDiv = document.getElementById('solution');
185
- const thoughtsContent = document.getElementById('thoughtsContent');
186
- const answerContent = document.getElementById('answerContent');
187
- const thoughtsToggle = document.getElementById('thoughtsToggle');
188
- const thoughtsBox = document.getElementById('thoughtsBox');
189
- const imagePreview = document.getElementById('imagePreview');
190
- const previewImage = document.getElementById('previewImage');
191
-
192
- // Fonction pour formater le temps écoulé
193
- function formatElapsedTime(seconds) {
194
- return `${seconds}s`;
195
- }
196
-
197
- // Fonction pour nettoyer et préparer le texte LaTeX
198
- function prepareMathContent(content) {
199
- // Protège les expressions LaTeX déjà correctement formatées
200
- content = content.replace(/\$\$(.*?)\$\$/g, '[[DISPLAY_MATH_$1]]');
201
- content = content.replace(/\$(.*?)\$/g, '[[INLINE_MATH_$1]]');
202
-
203
- // Convertit les expressions potentiellement non formatées
204
- content = content.replace(/\\boxed\{(.*?)\}/g, '$\\boxed{$1}$');
205
- content = content.replace(/\\frac\{(.*?)\}\{(.*?)\}/g, '$\\frac{$1}{$2}$');
206
- content = content.replace(/\\cos/g, '$\\cos$');
207
- content = content.replace(/\\sin/g, '$\\sin$');
208
- content = content.replace(/\\theta/g, '$\\theta$');
209
- content = content.replace(/\\alpha/g, '$\\alpha$');
210
- content = content.replace(/e\^{([^}]+)}/g, '$e^{$1}$');
211
-
212
- // Restaure les expressions protégées
213
- content = content.replace(/\[\[DISPLAY_MATH_(.*?)\]\]/g, '$$$$1$$');
214
- content = content.replace(/\[\[INLINE_MATH_(.*?)\]\]/g, '$$$1$');
215
-
216
- return content;
217
- }
218
-
219
- // Gestion du toggle des pensées
220
- thoughtsToggle.addEventListener('click', () => {
221
- thoughtsBox.classList.toggle('open');
222
- thoughtsToggle.querySelector('svg').classList.toggle('rotate-180');
223
- });
224
-
225
- // Gestion de la prévisualisation des images
226
- imageInput.addEventListener('change', function(e) {
227
- const file = this.files[0];
228
- if (file) {
229
- const reader = new FileReader();
230
- reader.onload = function(e) {
231
- previewImage.src = e.target.result;
232
- imagePreview.classList.remove('hidden');
233
- }
234
- reader.readAsDataURL(file);
235
- } else {
236
- previewImage.src = "";
237
- imagePreview.classList.add('hidden');
238
- }
239
- });
240
-
241
- // Gestion du drag & drop
242
- const dropZone = document.querySelector('.uploadArea');
243
-
244
- ['dragenter', 'dragover', 'dragleave', 'drop'].forEach(eventName => {
245
- dropZone.addEventListener(eventName, preventDefaults, false);
246
- });
247
-
248
- function preventDefaults(e) {
249
- e.preventDefault();
250
- e.stopPropagation();
251
- }
252
-
253
- ['dragenter', 'dragover'].forEach(eventName => {
254
- dropZone.addEventListener(eventName, highlight, false);
255
- });
256
-
257
- ['dragleave', 'drop'].forEach(eventName => {
258
- dropZone.addEventListener(eventName, unhighlight, false);
259
- });
260
-
261
- function highlight(e) {
262
- dropZone.classList.add('border-blue-400');
263
- }
264
-
265
- function unhighlight(e) {
266
- dropZone.classList.remove('border-blue-400');
267
- }
268
-
269
- dropZone.addEventListener('drop', handleDrop, false);
270
-
271
- function handleDrop(e) {
272
- const dt = e.dataTransfer;
273
- const files = dt.files;
274
-
275
- if (files.length) {
276
- imageInput.files = files;
277
- const file = files[0];
278
- const reader = new FileReader();
279
- reader.onload = function(e) {
280
- previewImage.src = e.target.result;
281
- imagePreview.classList.remove('hidden');
282
- }
283
- reader.readAsDataURL(file);
284
- }
285
- }
286
-
287
- // Gestion de la soumission du formulaire et du streaming
288
- form.addEventListener('submit', async (event) => {
289
- event.preventDefault();
290
- const file = imageInput.files[0];
291
- if (!file) {
292
- alert('Veuillez sélectionner une image.');
293
- return;
294
- }
295
-
296
- // Reset UI
297
- loader.classList.remove('hidden');
298
- solutionDiv.classList.add('hidden');
299
- thoughtsContent.innerHTML = '';
300
- answerContent.innerHTML = '';
301
- thoughtsBox.classList.add('open');
302
-
303
- const formData = new FormData();
304
- formData.append('image', file);
305
-
306
- try {
307
- let currentMode = null;
308
- const response = await fetch('/solve', {
309
- method: 'POST',
310
- body: formData
311
- });
312
-
313
- const reader = response.body.getReader();
314
- const decoder = new TextDecoder();
315
- let buffer = '';
316
-
317
- while (true) {
318
- const { done, value } = await reader.read();
319
- if (done) break;
320
-
321
- buffer += decoder.decode(value, { stream: true });
322
- let eolIndex;
323
-
324
- while ((eolIndex = buffer.indexOf('\n\n')) >= 0) {
325
- const line = buffer.slice(0, eolIndex).trim();
326
- buffer = buffer.slice(eolIndex + 2);
327
-
328
- if (line.startsWith('data:')) {
329
- const data = JSON.parse(line.slice(5));
330
-
331
- if (data.mode) {
332
- currentMode = data.mode;
333
- loader.classList.add('hidden');
334
- solutionDiv.classList.remove('hidden');
335
- }
336
-
337
- if (data.content) {
338
- const content = prepareMathContent(data.content);
339
- const timeString = data.elapsed_time ? ` <span class="text-blue-400">(${formatElapsedTime(data.elapsed_time)})</span> ` : '';
340
-
341
- if (currentMode === 'thinking') {
342
- thoughtsContent.innerHTML += `<p>${timeString}${content}</p>`;
343
- thoughtsContent.scrollTop = thoughtsContent.scrollHeight;
344
- } else if (currentMode === 'answering') {
345
- answerContent.innerHTML += content;
346
- if (window.MathJax) {
347
- MathJax.Hub.Queue(["Typeset", MathJax.Hub, answerContent]);
348
- }
349
- }
350
- }
351
-
352
- // Mettre à jour MathJax pour le contenu des pensées aussi
353
- if (window.MathJax) {
354
- MathJax.Hub.Queue(["Typeset", MathJax.Hub, thoughtsContent]);
355
- }
356
- }
357
- }
358
- }
359
-
360
- } catch (error) {
361
- console.error('Erreur:', error);
362
- alert('Une erreur est survenue lors du traitement de la requête.');
363
- loader.classList.add('hidden');
364
- }
365
- });
366
- });
367
- </script>
368
- </body>
369
- </html>