Docfile commited on
Commit
42082ec
·
verified ·
1 Parent(s): 3e1983c

Create index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +357 -0
templates/index.html ADDED
@@ -0,0 +1,357 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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>
9
+ window.MathJax = {
10
+ tex: {
11
+ inlineMath: [['$', '$'], ['\\(', '\\)']],
12
+ displayMath: [['$$', '$$'], ['\\[', '\\]']],
13
+ processEscapes: true,
14
+ packages: ['base', 'ams', 'noerrors', 'noundefined', 'boldsymbol', 'color', 'verb']
15
+ },
16
+ options: {
17
+ ignoreHtmlClass: 'tex2jax_ignore',
18
+ processHtmlClass: 'tex2jax_process'
19
+ },
20
+ svg: {
21
+ fontCache: 'global'
22
+ }
23
+ };
24
+ </script>
25
+ <script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
26
+ <script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
27
+ <style>
28
+ @import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600;700&display=swap');
29
+
30
+ body {
31
+ font-family: 'Space Grotesk', sans-serif;
32
+ background-color: white;
33
+ }
34
+
35
+ .uploadArea {
36
+ background: #f3f4f6;
37
+ border: 2px dashed #d1d5db;
38
+ }
39
+
40
+ .uploadArea:hover {
41
+ border-color: #3b82f6;
42
+ transform: translateY(-2px);
43
+ }
44
+
45
+ .blue-button {
46
+ background: #3b82f6;
47
+ transition: all 0.3s ease;
48
+ }
49
+
50
+ .blue-button:hover {
51
+ background: #2563eb;
52
+ transform: translateY(-2px);
53
+ }
54
+
55
+ .loader {
56
+ width: 48px;
57
+ height: 48px;
58
+ border: 3px solid #3b82f6;
59
+ border-bottom-color: transparent;
60
+ border-radius: 50%;
61
+ display: inline-block;
62
+ box-sizing: border-box;
63
+ animation: rotation 1s linear infinite;
64
+ }
65
+
66
+ @keyframes rotation {
67
+ 0% { transform: rotate(0deg); }
68
+ 100% { transform: rotate(360deg); }
69
+ }
70
+
71
+ .thought-box {
72
+ transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
73
+ max-height: 0;
74
+ overflow: hidden;
75
+ }
76
+
77
+ .thought-box.open {
78
+ max-height: 1000px;
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
+ }
93
+
94
+ #thoughtsContent, #answerContent {
95
+ max-height: 500px;
96
+ overflow-y: auto;
97
+ }
98
+
99
+ .timestamp {
100
+ color: #3b82f6;
101
+ margin-left: 10px;
102
+ font-size: 0.9em;
103
+ }
104
+ </style>
105
+ </head>
106
+ <body class="p-4">
107
+ <div class="w-full">
108
+ <div class="p-8">
109
+ <div class="text-center mb-12">
110
+ <h1 class="text-4xl font-bold text-blue-600 mb-4">Mariam M-0</h1>
111
+ <p class="text-gray-600 text-lg">Solution Mathématique Intelligente</p>
112
+ </div>
113
+
114
+ <form id="problemForm" class="space-y-8" enctype="multipart/form-data">
115
+ <div class="relative">
116
+ <div class="uploadArea p-12 text-center transition-all duration-300 cursor-pointer">
117
+ <input type="file" id="imageInput" name="image" accept="image/*" class="absolute inset-0 w-full h-full opacity-0 cursor-pointer">
118
+ <div class="space-y-4">
119
+ <div class="w-20 h-20 mx-auto border-2 border-blue-400 rounded-full flex items-center justify-center">
120
+ <svg class="w-10 h-10 text-blue-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
121
+ <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" />
122
+ </svg>
123
+ </div>
124
+ <div class="text-gray-700 text-lg font-medium">Déposez votre image ici</div>
125
+ <div class="text-gray-500 text-sm">ou cliquez pour sélectionner</div>
126
+ </div>
127
+ </div>
128
+ <div id="imagePreview" class="preview-container hidden">
129
+ <img id="previewImage" src="#" alt="Prévisualisation de l'image" class="preview-image">
130
+ </div>
131
+ </div>
132
+
133
+ <button type="submit" class="blue-button w-full py-4 text-white font-medium text-lg transition-all duration-300">
134
+ Résoudre le problème
135
+ </button>
136
+ </form>
137
+
138
+ <div id="loader" class="hidden mt-12">
139
+ <div class="flex flex-col items-center justify-center space-y-4">
140
+ <span class="loader"></span>
141
+ <div class="text-gray-600 text-lg">Analyse en cours...</div>
142
+ </div>
143
+ </div>
144
+
145
+ <div id="solution" class="hidden mt-12 space-y-8">
146
+ <div class="border-t pt-6">
147
+ <button id="thoughtsToggle" class="w-full flex justify-between items-center text-left text-lg font-medium text-gray-700 hover:text-blue-600 transition-colors">
148
+ <div class="flex items-center">
149
+ <span>Processus de Réflexion</span>
150
+ <span id="timestamp" class="timestamp"></span>
151
+ </div>
152
+ <svg class="w-6 h-6 transform transition-transform duration-300" fill="none" stroke="currentColor" viewBox="0 0 24 24">
153
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"/>
154
+ </svg>
155
+ </button>
156
+ <div id="thoughtsBox" class="thought-box">
157
+ <div id="thoughtsContent" class="prose max-w-none text-gray-600 mt-4"></div>
158
+ </div>
159
+ </div>
160
+
161
+ <div class="border-t pt-8">
162
+ <h3 class="text-2xl font-bold text-gray-800 mb-6">Solution</h3>
163
+ <div id="answerContent" class="prose max-w-none text-gray-700"></div>
164
+ </div>
165
+ </div>
166
+ </div>
167
+ </div>
168
+
169
+ <script>
170
+ document.addEventListener('DOMContentLoaded', () => {
171
+ const form = document.getElementById('problemForm');
172
+ const imageInput = document.getElementById('imageInput');
173
+ const loader = document.getElementById('loader');
174
+ const solutionDiv = document.getElementById('solution');
175
+ const thoughtsContent = document.getElementById('thoughtsContent');
176
+ const answerContent = document.getElementById('answerContent');
177
+ const thoughtsToggle = document.getElementById('thoughtsToggle');
178
+ const thoughtsBox = document.getElementById('thoughtsBox');
179
+ const imagePreview = document.getElementById('imagePreview');
180
+ const previewImage = document.getElementById('previewImage');
181
+ const timestamp = document.getElementById('timestamp');
182
+
183
+ let startTime = null;
184
+ let timerInterval = null;
185
+
186
+ function updateTimestamp() {
187
+ if (startTime) {
188
+ const elapsed = Math.floor((Date.now() - startTime) / 1000);
189
+ timestamp.textContent = elapsed + "s";
190
+ }
191
+ }
192
+
193
+ function startTimer() {
194
+ startTime = Date.now();
195
+ timerInterval = setInterval(updateTimestamp, 1000);
196
+ updateTimestamp();
197
+ }
198
+
199
+ function stopTimer() {
200
+ if (timerInterval) {
201
+ clearInterval(timerInterval);
202
+ timerInterval = null;
203
+ }
204
+ startTime = null;
205
+ timestamp.textContent = "";
206
+ }
207
+
208
+ thoughtsToggle.addEventListener('click', () => {
209
+ thoughtsBox.classList.toggle('open');
210
+ thoughtsToggle.querySelector('svg').classList.toggle('rotate-180');
211
+ });
212
+
213
+ imageInput.addEventListener('change', function(e) {
214
+ const file = this.files[0];
215
+ if (file) {
216
+ const reader = new FileReader();
217
+ reader.onload = function(e) {
218
+ previewImage.src = e.target.result;
219
+ imagePreview.classList.remove('hidden');
220
+ }
221
+ reader.readAsDataURL(file);
222
+ } else {
223
+ previewImage.src = "";
224
+ imagePreview.classList.add('hidden');
225
+ }
226
+ });
227
+
228
+ const dropZone = document.querySelector('.uploadArea');
229
+
230
+ ['dragenter', 'dragover', 'dragleave', 'drop'].forEach(eventName => {
231
+ dropZone.addEventListener(eventName, preventDefaults, false);
232
+ });
233
+
234
+ function preventDefaults(e) {
235
+ e.preventDefault();
236
+ e.stopPropagation();
237
+ }
238
+
239
+ ['dragenter', 'dragover'].forEach(eventName => {
240
+ dropZone.addEventListener(eventName, highlight, false);
241
+ });
242
+
243
+ ['dragleave', 'drop'].forEach(eventName => {
244
+ dropZone.addEventListener(eventName, unhighlight, false);
245
+ });
246
+
247
+ function highlight(e) {
248
+ dropZone.classList.add('border-blue-400');
249
+ }
250
+
251
+ function unhighlight(e) {
252
+ dropZone.classList.remove('border-blue-400');
253
+ }
254
+
255
+ dropZone.addEventListener('drop', handleDrop, false);
256
+
257
+ function handleDrop(e) {
258
+ const dt = e.dataTransfer;
259
+ const files = dt.files;
260
+
261
+ if (files.length) {
262
+ imageInput.files = files;
263
+ const file = files[0];
264
+ const reader = new FileReader();
265
+ reader.onload = function(e) {
266
+ previewImage.src = e.target.result;
267
+ imagePreview.classList.remove('hidden');
268
+ }
269
+ reader.readAsDataURL(file);
270
+ }
271
+ }
272
+
273
+ form.addEventListener('submit', async (event) => {
274
+ event.preventDefault();
275
+ const file = imageInput.files[0];
276
+ if (!file) {
277
+ alert('Veuillez sélectionner une image.');
278
+ return;
279
+ }
280
+
281
+ startTimer();
282
+
283
+ loader.classList.remove('hidden');
284
+ solutionDiv.classList.add('hidden');
285
+ thoughtsContent.innerHTML = '';
286
+ answerContent.innerHTML = '';
287
+ thoughtsBox.classList.add('open');
288
+
289
+ const formData = new FormData();
290
+ formData.append('image', file);
291
+
292
+ try {
293
+ let currentMode = null;
294
+ const response = await fetch('/solve', {
295
+ method: 'POST',
296
+ body: formData
297
+ });
298
+
299
+ const reader = response.body.getReader();
300
+ const decoder = new TextDecoder();
301
+ let buffer = '';
302
+
303
+ while (true) {
304
+ const { done, value } = await reader.read();
305
+ if (done) {
306
+ stopTimer();
307
+ break;
308
+ }
309
+
310
+ buffer += decoder.decode(value, { stream: true });
311
+ let eolIndex;
312
+
313
+ while ((eolIndex = buffer.indexOf('\n\n')) >= 0) {
314
+ const line = buffer.slice(0, eolIndex).trim();
315
+ buffer = buffer.slice(eolIndex + 2);
316
+
317
+ if (line.startsWith('data:')) {
318
+ const data = JSON.parse(line.slice(5));
319
+
320
+ if (data.mode) {
321
+ currentMode = data.mode;
322
+ loader.classList.add('hidden');
323
+ solutionDiv.classList.remove('hidden');
324
+ }
325
+
326
+ if (data.content) {
327
+ const content = data.content;
328
+ if (currentMode === 'thinking') {
329
+ thoughtsContent.innerHTML += `<p>${marked.parse(content)}</p>`;
330
+ thoughtsContent.scrollTop = thoughtsContent.scrollHeight;
331
+ } else if (currentMode === 'answering') {
332
+ // Applique le rendu Markdown
333
+ answerContent.innerHTML += marked.parse(content);
334
+ // Applique le rendu MathJax
335
+ if (window.MathJax) {
336
+ MathJax.typesetPromise([answerContent]).then(() => {
337
+ // Le rendu MathJax est terminé, faites défiler vers le bas si nécessaire
338
+ answerContent.scrollTop = answerContent.scrollHeight;
339
+ }).catch((err) => console.log('MathJax error:', err));
340
+ }
341
+ }
342
+ }
343
+ }
344
+ }
345
+ }
346
+
347
+ } catch (error) {
348
+ console.error('Erreur:', error);
349
+ alert('Une erreur est survenue lors du traitement de la requête.');
350
+ loader.classList.add('hidden');
351
+ stopTimer();
352
+ }
353
+ });
354
+ });
355
+ </script>
356
+ </body>
357
+ </html>