Docfile commited on
Commit
29877cd
·
verified ·
1 Parent(s): 5d1c966

Create index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +335 -0
templates/index.html ADDED
@@ -0,0 +1,335 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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: linear-gradient(125deg, #000428 0%, #004e92 100%);
32
+ min-height: 100vh;
33
+ }
34
+
35
+ .glass-card {
36
+ background: rgba(255, 255, 255, 0.05);
37
+ backdrop-filter: blur(10px);
38
+ border: 1px solid rgba(255, 255, 255, 0.1);
39
+ box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
40
+ }
41
+
42
+ .uploadArea {
43
+ background: linear-gradient(145deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0.02) 100%);
44
+ border: 2px dashed rgba(255, 255, 255, 0.2);
45
+ }
46
+
47
+ .uploadArea:hover {
48
+ border-color: #60A5FA;
49
+ transform: translateY(-2px);
50
+ }
51
+
52
+ .neon-button {
53
+ background: linear-gradient(90deg, #4F46E5 0%, #60A5FA 100%);
54
+ box-shadow: 0 0 15px rgba(79, 70, 229, 0.5);
55
+ transition: all 0.3s ease;
56
+ }
57
+
58
+ .neon-button:hover {
59
+ box-shadow: 0 0 25px rgba(79, 70, 229, 0.7);
60
+ transform: translateY(-2px);
61
+ }
62
+
63
+ .loader {
64
+ width: 48px;
65
+ height: 48px;
66
+ border: 3px solid #FFF;
67
+ border-bottom-color: transparent;
68
+ border-radius: 50%;
69
+ display: inline-block;
70
+ box-sizing: border-box;
71
+ animation: rotation 1s linear infinite;
72
+ }
73
+
74
+ @keyframes rotation {
75
+ 0% { transform: rotate(0deg); }
76
+ 100% { transform: rotate(360deg); }
77
+ }
78
+
79
+ .thought-box {
80
+ transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
81
+ max-height: 0;
82
+ overflow: hidden;
83
+ }
84
+
85
+ .thought-box.open {
86
+ max-height: 1000px;
87
+ }
88
+
89
+ .glow {
90
+ animation: glow 2s ease-in-out infinite alternate;
91
+ }
92
+
93
+ @keyframes glow {
94
+ from { text-shadow: 0 0 10px #fff, 0 0 20px #fff, 0 0 30px #60A5FA; }
95
+ to { text-shadow: 0 0 20px #fff, 0 0 30px #4F46E5, 0 0 40px #4F46E5; }
96
+ }
97
+
98
+ .preview-container {
99
+ display: flex;
100
+ justify-content: center;
101
+ align-items: center;
102
+ margin-top: 20px;
103
+ }
104
+
105
+ .preview-image {
106
+ max-width: 300px;
107
+ max-height: 300px;
108
+ border-radius: 8px;
109
+ box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
110
+ }
111
+
112
+ #thoughtsContent, #answerContent {
113
+ max-height: 500px;
114
+ overflow-y: auto;
115
+ }
116
+ </style>
117
+ </head>
118
+ <body class="p-4 md:p-8">
119
+ <div class="container mx-auto max-w-4xl">
120
+ <div class="glass-card rounded-3xl p-8 md:p-12">
121
+ <div class="text-center mb-12">
122
+ <h1 class="text-5xl font-bold text-white glow mb-4">Mariam M-0</h1>
123
+ <p class="text-blue-200 text-lg">Solution Mathématique Intelligente</p>
124
+ </div>
125
+
126
+ <form id="problemForm" class="space-y-8" enctype="multipart/form-data">
127
+ <div class="relative">
128
+ <div class="uploadArea rounded-2xl p-12 text-center transition-all duration-300 cursor-pointer">
129
+ <input type="file" id="imageInput" name="image" accept="image/*" class="absolute inset-0 w-full h-full opacity-0 cursor-pointer">
130
+ <div class="space-y-4">
131
+ <div class="w-20 h-20 mx-auto border-2 border-blue-400 rounded-full flex items-center justify-center">
132
+ <svg class="w-10 h-10 text-blue-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
133
+ <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" />
134
+ </svg>
135
+ </div>
136
+ <div class="text-blue-200 text-lg font-medium">Déposez votre image ici</div>
137
+ <div class="text-blue-300/60 text-sm">ou cliquez pour sélectionner</div>
138
+ </div>
139
+ </div>
140
+ <div id="imagePreview" class="preview-container hidden">
141
+ <img id="previewImage" src="#" alt="Prévisualisation de l'image" class="preview-image">
142
+ </div>
143
+ </div>
144
+
145
+ <button type="submit" class="neon-button w-full py-4 rounded-xl text-white font-medium text-lg transition-all duration-300">
146
+ Résoudre le problème
147
+ </button>
148
+ </form>
149
+
150
+ <div id="loader" class="hidden mt-12">
151
+ <div class="flex flex-col items-center justify-center space-y-4">
152
+ <span class="loader"></span>
153
+ <div class="text-blue-200 text-lg">Analyse en cours...</div>
154
+ </div>
155
+ </div>
156
+
157
+ <div id="solution" class="hidden mt-12 space-y-8">
158
+ <div class="glass-card rounded-2xl p-6">
159
+ <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">
160
+ <span>Processus de Réflexion</span>
161
+ <svg class="w-6 h-6 transform transition-transform duration-300" fill="none" stroke="currentColor" viewBox="0 0 24 24">
162
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"/>
163
+ </svg>
164
+ </button>
165
+ <div id="thoughtsBox" class="thought-box">
166
+ <div id="thoughtsContent" class="prose prose-invert max-w-none text-blue-100 mt-4"></div>
167
+ </div>
168
+ </div>
169
+
170
+ <div class="glass-card rounded-2xl p-8">
171
+ <h3 class="text-2xl font-bold text-white mb-6">Solution</h3>
172
+ <div id="answerContent" class="prose prose-invert max-w-none text-blue-100"></div>
173
+ </div>
174
+ </div>
175
+ </div>
176
+ </div>
177
+
178
+ <script>
179
+ document.addEventListener('DOMContentLoaded', () => {
180
+ const form = document.getElementById('problemForm');
181
+ const imageInput = document.getElementById('imageInput');
182
+ const loader = document.getElementById('loader');
183
+ const solutionDiv = document.getElementById('solution');
184
+ const thoughtsContent = document.getElementById('thoughtsContent');
185
+ const answerContent = document.getElementById('answerContent');
186
+ const thoughtsToggle = document.getElementById('thoughtsToggle');
187
+ const thoughtsBox = document.getElementById('thoughtsBox');
188
+ const imagePreview = document.getElementById('imagePreview');
189
+ const previewImage = document.getElementById('previewImage');
190
+
191
+ thoughtsToggle.addEventListener('click', () => {
192
+ thoughtsBox.classList.toggle('open');
193
+ thoughtsToggle.querySelector('svg').classList.toggle('rotate-180');
194
+ });
195
+
196
+ imageInput.addEventListener('change', function(e) {
197
+ const file = this.files[0];
198
+ if (file) {
199
+ const reader = new FileReader();
200
+ reader.onload = function(e) {
201
+ previewImage.src = e.target.result;
202
+ imagePreview.classList.remove('hidden');
203
+ }
204
+ reader.readAsDataURL(file);
205
+ } else {
206
+ previewImage.src = "";
207
+ imagePreview.classList.add('hidden');
208
+ }
209
+ });
210
+
211
+ const dropZone = document.querySelector('.uploadArea');
212
+
213
+ ['dragenter', 'dragover', 'dragleave', 'drop'].forEach(eventName => {
214
+ dropZone.addEventListener(eventName, preventDefaults, false);
215
+ });
216
+
217
+ function preventDefaults(e) {
218
+ e.preventDefault();
219
+ e.stopPropagation();
220
+ }
221
+
222
+ ['dragenter', 'dragover'].forEach(eventName => {
223
+ dropZone.addEventListener(eventName, highlight, false);
224
+ });
225
+
226
+ ['dragleave', 'drop'].forEach(eventName => {
227
+ dropZone.addEventListener(eventName, unhighlight, false);
228
+ });
229
+
230
+ function highlight(e) {
231
+ dropZone.classList.add('border-blue-400');
232
+ }
233
+
234
+ function unhighlight(e) {
235
+ dropZone.classList.remove('border-blue-400');
236
+ }
237
+
238
+ dropZone.addEventListener('drop', handleDrop, false);
239
+
240
+ function handleDrop(e) {
241
+ const dt = e.dataTransfer;
242
+ const files = dt.files;
243
+
244
+ if (files.length) {
245
+ imageInput.files = files;
246
+ const file = files[0];
247
+ const reader = new FileReader();
248
+ reader.onload = function(e) {
249
+ previewImage.src = e.target.result;
250
+ imagePreview.classList.remove('hidden');
251
+ }
252
+ reader.readAsDataURL(file);
253
+ }
254
+ }
255
+
256
+ form.addEventListener('submit', async (event) => {
257
+ event.preventDefault();
258
+ const file = imageInput.files[0];
259
+ if (!file) {
260
+ alert('Veuillez sélectionner une image.');
261
+ return;
262
+ }
263
+
264
+ loader.classList.remove('hidden');
265
+ solutionDiv.classList.add('hidden');
266
+ thoughtsContent.innerHTML = '';
267
+ answerContent.innerHTML = '';
268
+ thoughtsBox.classList.add('open');
269
+
270
+ const formData = new FormData();
271
+ formData.append('image', file);
272
+
273
+ try {
274
+ let currentMode = null;
275
+ const response = await fetch('/solve', {
276
+ method: 'POST',
277
+ body: formData
278
+ });
279
+
280
+ const reader = response.body.getReader();
281
+ const decoder = new TextDecoder();
282
+ let buffer = '';
283
+
284
+ while (true) {
285
+ const { done, value } = await reader.read();
286
+ if (done) break;
287
+
288
+ buffer += decoder.decode(value, { stream: true });
289
+ let eolIndex;
290
+
291
+ while ((eolIndex = buffer.indexOf('\n\n')) >= 0) {
292
+ const line = buffer.slice(0, eolIndex).trim();
293
+ buffer = buffer.slice(eolIndex + 2);
294
+
295
+ if (line.startsWith('data:')) {
296
+ const data = JSON.parse(line.slice(5));
297
+
298
+ if (data.mode) {
299
+ currentMode = data.mode;
300
+ loader.classList.add('hidden');
301
+ solutionDiv.classList.remove('hidden');
302
+ }
303
+
304
+ if (data.content) {
305
+ const content = data.content;
306
+ if (currentMode === 'thinking') {
307
+ const timestamp = new Date().toLocaleTimeString('fr-FR', {
308
+ hour: '2-digit',
309
+ minute: '2-digit',
310
+ second: '2-digit',
311
+ hour12: false
312
+ });
313
+ thoughtsContent.innerHTML += `<p><span class="text-blue-400">[${timestamp}]</span> ${content}</p>`;
314
+ thoughtsContent.scrollTop = thoughtsContent.scrollHeight;
315
+ } else if (currentMode === 'answering') {
316
+ answerContent.innerHTML += content;
317
+ if (window.MathJax) {
318
+ MathJax.typesetPromise([answerContent]).catch((err) => console.log('MathJax error:', err));
319
+ }
320
+ }
321
+ }
322
+ }
323
+ }
324
+ }
325
+
326
+ } catch (error) {
327
+ console.error('Erreur:', error);
328
+ alert('Une erreur est survenue lors du traitement de la requête.');
329
+ loader.classList.add('hidden');
330
+ }
331
+ });
332
+ });
333
+ </script>
334
+ </body>
335
+ </html>