Docfile commited on
Commit
3c9e253
·
verified ·
1 Parent(s): 4d35288

Delete templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +0 -358
templates/index.html DELETED
@@ -1,358 +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>
9
- window.MathJax = {
10
- tex: {
11
- inlineMath: [['$', '$'], ['\\(', '\\)']],
12
- displayMath: [['$$', '$$'], ['\\[', '\\]']],
13
- processEscapes: true,
14
- packages: ['base', 'ams', 'noerrors', 'noundefined']
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
- <style>
27
- @import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600;700&display=swap');
28
-
29
- body {
30
- font-family: 'Space Grotesk', sans-serif;
31
- background-color: white;
32
- }
33
-
34
- .uploadArea {
35
- background: #f3f4f6;
36
- border: 2px dashed #d1d5db;
37
- }
38
-
39
- .uploadArea:hover {
40
- border-color: #3b82f6;
41
- transform: translateY(-2px);
42
- }
43
-
44
- .blue-button {
45
- background: #3b82f6;
46
- transition: all 0.3s ease;
47
- }
48
-
49
- .blue-button:hover {
50
- background: #2563eb;
51
- transform: translateY(-2px);
52
- }
53
-
54
- .loader {
55
- width: 48px;
56
- height: 48px;
57
- border: 3px solid #3b82f6;
58
- border-bottom-color: transparent;
59
- border-radius: 50%;
60
- display: inline-block;
61
- box-sizing: border-box;
62
- animation: rotation 1s linear infinite;
63
- }
64
-
65
- @keyframes rotation {
66
- 0% { transform: rotate(0deg); }
67
- 100% { transform: rotate(360deg); }
68
- }
69
-
70
- .thought-box {
71
- transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
72
- max-height: 0;
73
- overflow: hidden;
74
- }
75
-
76
- .thought-box.open {
77
- max-height: 1000px;
78
- }
79
-
80
- .preview-container {
81
- display: flex;
82
- justify-content: center;
83
- align-items: center;
84
- margin-top: 20px;
85
- }
86
-
87
- .preview-image {
88
- max-width: 300px;
89
- max-height: 300px;
90
- border-radius: 8px;
91
- }
92
-
93
- #thoughtsContent, #answerContent {
94
- max-height: 500px;
95
- overflow-y: auto;
96
- }
97
-
98
- .timestamp {
99
- color: #3b82f6;
100
- margin-left: 10px;
101
- font-size: 0.9em;
102
- }
103
- </style>
104
- </head>
105
- <body class="p-4">
106
- <div class="w-full">
107
- <div class="p-8">
108
- <div class="text-center mb-12">
109
- <h1 class="text-4xl font-bold text-blue-600 mb-4">Mariam M-0</h1>
110
- <p class="text-gray-600 text-lg">Solution Mathématique Intelligente</p>
111
- </div>
112
-
113
- <form id="problemForm" class="space-y-8" enctype="multipart/form-data">
114
- <div class="relative">
115
- <div class="uploadArea p-12 text-center transition-all duration-300 cursor-pointer">
116
- <input type="file" id="imageInput" name="image" accept="image/*" class="absolute inset-0 w-full h-full opacity-0 cursor-pointer">
117
- <div class="space-y-4">
118
- <div class="w-20 h-20 mx-auto border-2 border-blue-400 rounded-full flex items-center justify-center">
119
- <svg class="w-10 h-10 text-blue-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
120
- <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" />
121
- </svg>
122
- </div>
123
- <div class="text-gray-700 text-lg font-medium">Déposez votre image ici</div>
124
- <div class="text-gray-500 text-sm">ou cliquez pour sélectionner</div>
125
- </div>
126
- </div>
127
- <div id="imagePreview" class="preview-container hidden">
128
- <img id="previewImage" src="#" alt="Prévisualisation de l'image" class="preview-image">
129
- </div>
130
- </div>
131
-
132
- <button type="submit" class="blue-button w-full py-4 text-white font-medium text-lg transition-all duration-300">
133
- Résoudre le problème
134
- </button>
135
- </form>
136
-
137
- <div id="loader" class="hidden mt-12">
138
- <div class="flex flex-col items-center justify-center space-y-4">
139
- <span class="loader"></span>
140
- <div class="text-gray-600 text-lg">Analyse en cours...</div>
141
- </div>
142
- </div>
143
-
144
- <div id="solution" class="hidden mt-12 space-y-8">
145
- <div class="border-t pt-6">
146
- <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">
147
- <div class="flex items-center">
148
- <span>Processus de Réflexion</span>
149
- <span id="timestamp" class="timestamp"></span>
150
- </div>
151
- <svg class="w-6 h-6 transform transition-transform duration-300" fill="none" stroke="currentColor" viewBox="0 0 24 24">
152
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"/>
153
- </svg>
154
- </button>
155
- <div id="thoughtsBox" class="thought-box">
156
- <div id="thoughtsContent" class="prose max-w-none text-gray-600 mt-4"></div>
157
- </div>
158
- </div>
159
-
160
- <div class="border-t pt-8">
161
- <h3 class="text-2xl font-bold text-gray-800 mb-6">Solution</h3>
162
- <div id="answerContent" class="prose max-w-none text-gray-700"></div>
163
- </div>
164
- </div>
165
- </div>
166
- </div>
167
-
168
- <script>
169
-
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>${content}</p>`;
330
- if (window.MathJax) {
331
- MathJax.typesetPromise([thoughtsContent]).catch((err) =>
332
- console.log('MathJax error:', err)
333
- );
334
- }
335
- thoughtsContent.scrollTop = thoughtsContent.scrollHeight;
336
- } else if (currentMode === 'answering') {
337
- answerContent.innerHTML += content;
338
- if (window.MathJax) {
339
- MathJax.typesetPromise([answerContent]).catch((err) =>
340
- console.log('MathJax error:', err)
341
- );
342
- }
343
- }
344
- }
345
- }
346
- }
347
- }
348
- } catch (error) {
349
- console.error('Erreur:', error);
350
- alert('Une erreur est survenue lors du traitement de la requête.');
351
- loader.classList.add('hidden');
352
- stopTimer();
353
- }
354
- });
355
- });
356
- </script>
357
- </body>
358
- </html>