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

Create index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +316 -0
templates/index.html ADDED
@@ -0,0 +1,316 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ const form = document.getElementById('problemForm');
164
+ const imageInput = document.getElementById('imageInput');
165
+ const loader = document.getElementById('loader');
166
+ const solutionDiv = document.getElementById('solution');
167
+ const thoughtsContent = document.getElementById('thoughtsContent');
168
+ const answerContent = document.getElementById('answerContent');
169
+ const thoughtsToggle = document.getElementById('thoughtsToggle');
170
+ const thoughtsBox = document.getElementById('thoughtsBox');
171
+ const imagePreview = document.getElementById('imagePreview');
172
+ const previewImage = document.getElementById('previewImage');
173
+
174
+ thoughtsToggle.addEventListener('click', () => {
175
+ thoughtsBox.classList.toggle('open');
176
+ thoughtsToggle.querySelector('svg').classList.toggle('rotate-180');
177
+ });
178
+
179
+ // Image preview handling
180
+ imageInput.addEventListener('change', function(e) {
181
+ const file = this.files[0];
182
+ if (file) {
183
+ const reader = new FileReader();
184
+ reader.onload = function(e) {
185
+ previewImage.src = e.target.result;
186
+ imagePreview.classList.remove('hidden');
187
+ }
188
+ reader.readAsDataURL(file);
189
+ } else {
190
+ previewImage.src = "";
191
+ imagePreview.classList.add('hidden');
192
+ }
193
+ });
194
+
195
+ // Drag and drop handling
196
+ const dropZone = document.querySelector('.uploadArea');
197
+
198
+ ['dragenter', 'dragover', 'dragleave', 'drop'].forEach(eventName => {
199
+ dropZone.addEventListener(eventName, preventDefaults, false);
200
+ });
201
+
202
+ function preventDefaults(e) {
203
+ e.preventDefault();
204
+ e.stopPropagation();
205
+ }
206
+
207
+ ['dragenter', 'dragover'].forEach(eventName => {
208
+ dropZone.addEventListener(eventName, highlight, false);
209
+ });
210
+
211
+ ['dragleave', 'drop'].forEach(eventName => {
212
+ dropZone.addEventListener(eventName, unhighlight, false);
213
+ });
214
+
215
+ function highlight(e) {
216
+ dropZone.classList.add('border-blue-400');
217
+ }
218
+
219
+ function unhighlight(e) {
220
+ dropZone.classList.remove('border-blue-400');
221
+ }
222
+
223
+ dropZone.addEventListener('drop', handleDrop, false);
224
+
225
+ function handleDrop(e) {
226
+ const dt = e.dataTransfer;
227
+ const files = dt.files;
228
+
229
+ if (files.length) {
230
+ imageInput.files = files;
231
+ const file = files[0];
232
+ const reader = new FileReader();
233
+ reader.onload = function(e) {
234
+ previewImage.src = e.target.result;
235
+ imagePreview.classList.remove('hidden');
236
+ }
237
+ reader.readAsDataURL(file);
238
+ }
239
+ }
240
+
241
+ // Form submission and streaming
242
+ form.addEventListener('submit', async (event) => {
243
+ event.preventDefault();
244
+ const file = imageInput.files[0];
245
+ if (!file) {
246
+ alert('Veuillez sélectionner une image.');
247
+ return;
248
+ }
249
+
250
+ // Reset UI
251
+ loader.classList.remove('hidden');
252
+ solutionDiv.classList.add('hidden');
253
+ thoughtsContent.innerHTML = '';
254
+ answerContent.innerHTML = '';
255
+ thoughtsBox.classList.add('open');
256
+
257
+ const formData = new FormData();
258
+ formData.append('image', file);
259
+
260
+ try {
261
+ let currentMode = null;
262
+ const response = await fetch('/solve', {
263
+ method: 'POST',
264
+ body: formData
265
+ });
266
+
267
+ const reader = response.body.getReader();
268
+ const decoder = new TextDecoder();
269
+ let buffer = '';
270
+
271
+ while (true) {
272
+ const { done, value } = await reader.read();
273
+ if (done) break;
274
+
275
+ buffer += decoder.decode(value, { stream: true });
276
+ let eolIndex;
277
+
278
+ while ((eolIndex = buffer.indexOf('\n\n')) >= 0) {
279
+ const line = buffer.slice(0, eolIndex).trim();
280
+ buffer = buffer.slice(eolIndex + 2);
281
+
282
+ if (line.startsWith('data:')) {
283
+ const data = JSON.parse(line.slice(5));
284
+
285
+ if (data.mode) {
286
+ currentMode = data.mode;
287
+ loader.classList.add('hidden');
288
+ solutionDiv.classList.remove('hidden');
289
+ }
290
+
291
+ if (data.content) {
292
+ const content = data.content;
293
+ if (currentMode === 'thinking') {
294
+ thoughtsContent.innerHTML += `<p>${content}</p>`;
295
+ thoughtsContent.scrollTop = thoughtsContent.scrollHeight;
296
+ } else if (currentMode === 'answering') {
297
+ answerContent.innerHTML += content;
298
+ if (window.MathJax) {
299
+ MathJax.Hub.Queue(["Typeset", MathJax.Hub, answerContent]);
300
+ }
301
+ }
302
+ }
303
+ }
304
+ }
305
+ }
306
+
307
+ } catch (error) {
308
+ console.error('Erreur:', error);
309
+ alert('Une erreur est survenue lors du traitement de la requête.');
310
+ loader.classList.add('hidden');
311
+ }
312
+ });
313
+ });
314
+ </script>
315
+ </body>
316
+ </html>