Spaces:
Running
Running
Update templates/index.html
Browse files- templates/index.html +132 -71
templates/index.html
CHANGED
@@ -1,98 +1,159 @@
|
|
1 |
-
<!DOCTYPE html>
|
2 |
-
<html lang="
|
3 |
<head>
|
4 |
<meta charset="UTF-8">
|
5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
-
<title>
|
7 |
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/tailwind.min.css" rel="stylesheet">
|
8 |
-
<script src="https://
|
9 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
</head>
|
11 |
-
<body class="bg-
|
12 |
-
<div class="container mx-auto max-w-
|
13 |
-
<
|
|
|
|
|
|
|
|
|
|
|
14 |
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
<
|
20 |
-
|
21 |
-
|
|
|
|
|
|
|
|
|
|
|
22 |
</div>
|
23 |
-
|
24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
</div>
|
26 |
-
<button type="submit" class="w-full bg-blue-600 text-white font-bold py-3 px-6 rounded-lg hover:bg-blue-800 transition duration-300 ease-in-out">Solve</button>
|
27 |
-
</form>
|
28 |
|
29 |
-
|
30 |
-
|
31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
<summary class="p-4 cursor-pointer font-bold bg-gray-100 hover:bg-gray-200">Show/Hide Thoughts</summary>
|
37 |
-
<div id="thoughts" class="p-4">
|
38 |
-
<pre id="thoughtsContent" class="whitespace-pre-wrap font-mono"></pre>
|
39 |
</div>
|
40 |
-
</details>
|
41 |
-
<div id="answer" class="p-4 border border-gray-300 rounded-md">
|
42 |
-
<h3 class="font-bold mb-2">Answer:</h3>
|
43 |
-
<pre id="answerContent" class="whitespace-pre-wrap font-mono"></pre>
|
44 |
</div>
|
45 |
</div>
|
46 |
</div>
|
47 |
|
48 |
<script>
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
|
|
|
|
|
|
55 |
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
return;
|
62 |
-
}
|
63 |
|
64 |
-
|
65 |
-
|
|
|
|
|
|
|
|
|
|
|
66 |
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
|
71 |
-
|
72 |
-
|
73 |
-
method: 'POST',
|
74 |
-
body: formData,
|
75 |
-
});
|
76 |
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
|
82 |
-
|
83 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
|
85 |
-
|
86 |
-
|
87 |
-
|
|
|
|
|
88 |
}
|
89 |
-
}
|
90 |
-
console.error('Error:', error);
|
91 |
-
alert('An error occurred while processing the request.');
|
92 |
-
} finally {
|
93 |
-
// Cacher le loader
|
94 |
-
loader.classList.add('hidden');
|
95 |
-
}
|
96 |
});
|
97 |
</script>
|
98 |
</body>
|
|
|
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 | Résolveur de Problèmes Mathématiques</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 |
+
@keyframes pulse {
|
11 |
+
0% { transform: scale(1); }
|
12 |
+
50% { transform: scale(1.05); }
|
13 |
+
100% { transform: scale(1); }
|
14 |
+
}
|
15 |
+
.loader {
|
16 |
+
border-top-color: #3B82F6;
|
17 |
+
animation: spinner 1s linear infinite;
|
18 |
+
}
|
19 |
+
@keyframes spinner {
|
20 |
+
0% { transform: rotate(0deg); }
|
21 |
+
100% { transform: rotate(360deg); }
|
22 |
+
}
|
23 |
+
.thought-box {
|
24 |
+
transition: max-height 0.3s ease-out;
|
25 |
+
max-height: 0;
|
26 |
+
overflow: hidden;
|
27 |
+
}
|
28 |
+
.thought-box.open {
|
29 |
+
max-height: 500px;
|
30 |
+
}
|
31 |
+
</style>
|
32 |
</head>
|
33 |
+
<body class="bg-gradient-to-br from-blue-50 to-indigo-100 min-h-screen p-8">
|
34 |
+
<div class="container mx-auto max-w-3xl">
|
35 |
+
<div class="bg-white rounded-2xl shadow-xl p-8 mb-8">
|
36 |
+
<div class="flex items-center justify-center mb-8">
|
37 |
+
<h1 class="text-4xl font-bold bg-clip-text text-transparent bg-gradient-to-r from-blue-600 to-indigo-600">
|
38 |
+
Mariam M-0
|
39 |
+
</h1>
|
40 |
+
</div>
|
41 |
|
42 |
+
<form id="problemForm" class="space-y-6">
|
43 |
+
<div class="relative">
|
44 |
+
<div class="border-2 border-dashed border-gray-300 rounded-xl p-8 text-center hover:border-blue-500 transition-colors">
|
45 |
+
<input type="file" id="imageInput" accept="image/*" class="absolute inset-0 w-full h-full opacity-0 cursor-pointer">
|
46 |
+
<div class="space-y-2">
|
47 |
+
<svg class="mx-auto h-12 w-12 text-gray-400" stroke="currentColor" fill="none" viewBox="0 0 48 48">
|
48 |
+
<path d="M28 8H12a4 4 0 00-4 4v20m32-12v8m0 0v8a4 4 0 01-4 4H12a4 4 0 01-4-4v-4m32-4l-3.172-3.172a4 4 0 00-5.656 0L28 28M8 32l9.172-9.172a4 4 0 015.656 0L28 28m0 0l4 4m4-24h8m-4-4v8m-12 4h.02" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" />
|
49 |
+
</svg>
|
50 |
+
<div class="text-gray-600">
|
51 |
+
Glissez une image ou cliquez pour sélectionner
|
52 |
+
</div>
|
53 |
+
</div>
|
54 |
</div>
|
55 |
+
</div>
|
56 |
+
|
57 |
+
<button type="submit" class="w-full bg-gradient-to-r from-blue-600 to-indigo-600 text-white py-3 px-6 rounded-xl font-medium hover:from-blue-700 hover:to-indigo-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 transform transition-all hover:scale-105">
|
58 |
+
Résoudre
|
59 |
+
</button>
|
60 |
+
</form>
|
61 |
+
|
62 |
+
<div id="loader" class="hidden mt-8">
|
63 |
+
<div class="flex justify-center items-center">
|
64 |
+
<div class="loader ease-linear rounded-full border-4 border-t-4 border-gray-200 h-12 w-12"></div>
|
65 |
+
</div>
|
66 |
+
<div class="text-center mt-4 text-gray-600">Analyse en cours...</div>
|
67 |
</div>
|
|
|
|
|
68 |
|
69 |
+
<div id="solution" class="mt-8 hidden space-y-6">
|
70 |
+
<div class="bg-gray-50 rounded-xl p-4">
|
71 |
+
<button id="thoughtsToggle" class="w-full flex justify-between items-center text-left font-semibold text-gray-700 hover:text-blue-600">
|
72 |
+
<span>Processus de réflexion</span>
|
73 |
+
<svg class="w-5 h-5 transform transition-transform" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
74 |
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"/>
|
75 |
+
</svg>
|
76 |
+
</button>
|
77 |
+
<div id="thoughtsBox" class="thought-box mt-4">
|
78 |
+
<div id="thoughtsContent" class="prose max-w-none"></div>
|
79 |
+
</div>
|
80 |
+
</div>
|
81 |
|
82 |
+
<div class="bg-gradient-to-r from-blue-50 to-indigo-50 rounded-xl p-6">
|
83 |
+
<h3 class="font-bold text-xl mb-4 text-gray-800">Solution</h3>
|
84 |
+
<div id="answerContent" class="prose max-w-none"></div>
|
|
|
|
|
|
|
85 |
</div>
|
|
|
|
|
|
|
|
|
86 |
</div>
|
87 |
</div>
|
88 |
</div>
|
89 |
|
90 |
<script>
|
91 |
+
document.addEventListener('DOMContentLoaded', () => {
|
92 |
+
const form = document.getElementById('problemForm');
|
93 |
+
const imageInput = document.getElementById('imageInput');
|
94 |
+
const loader = document.getElementById('loader');
|
95 |
+
const solution = document.getElementById('solution');
|
96 |
+
const thoughtsContent = document.getElementById('thoughtsContent');
|
97 |
+
const answerContent = document.getElementById('answerContent');
|
98 |
+
const thoughtsToggle = document.getElementById('thoughtsToggle');
|
99 |
+
const thoughtsBox = document.getElementById('thoughtsBox');
|
100 |
|
101 |
+
// Toggle thoughts
|
102 |
+
thoughtsToggle.addEventListener('click', () => {
|
103 |
+
thoughtsBox.classList.toggle('open');
|
104 |
+
thoughtsToggle.querySelector('svg').classList.toggle('rotate-180');
|
105 |
+
});
|
|
|
|
|
106 |
|
107 |
+
form.addEventListener('submit', async (event) => {
|
108 |
+
event.preventDefault();
|
109 |
+
const file = imageInput.files[0];
|
110 |
+
if (!file) {
|
111 |
+
alert('Veuillez sélectionner une image.');
|
112 |
+
return;
|
113 |
+
}
|
114 |
|
115 |
+
// Show loader
|
116 |
+
loader.classList.remove('hidden');
|
117 |
+
solution.classList.add('hidden');
|
118 |
|
119 |
+
const formData = new FormData();
|
120 |
+
formData.append('image', file);
|
|
|
|
|
|
|
121 |
|
122 |
+
try {
|
123 |
+
const response = await fetch('/solve', {
|
124 |
+
method: 'POST',
|
125 |
+
body: formData,
|
126 |
+
});
|
127 |
+
const data = await response.json();
|
128 |
+
|
129 |
+
if (response.ok) {
|
130 |
+
thoughtsContent.innerHTML = data.thoughts;
|
131 |
+
answerContent.innerHTML = data.answer;
|
132 |
+
|
133 |
+
// Refresh MathJax
|
134 |
+
if (window.MathJax) {
|
135 |
+
MathJax.Hub.Queue(["Typeset", MathJax.Hub]);
|
136 |
+
}
|
137 |
|
138 |
+
loader.classList.add('hidden');
|
139 |
+
solution.classList.remove('hidden');
|
140 |
+
} else {
|
141 |
+
throw new Error(data.error || 'Une erreur est survenue');
|
142 |
+
}
|
143 |
+
} catch (error) {
|
144 |
+
console.error('Error:', error);
|
145 |
+
alert(error.message);
|
146 |
+
loader.classList.add('hidden');
|
147 |
+
}
|
148 |
+
});
|
149 |
|
150 |
+
// File input visualization
|
151 |
+
imageInput.addEventListener('change', function() {
|
152 |
+
const fileName = this.files[0]?.name;
|
153 |
+
if (fileName) {
|
154 |
+
this.parentElement.querySelector('.text-gray-600').textContent = fileName;
|
155 |
}
|
156 |
+
});
|
|
|
|
|
|
|
|
|
|
|
|
|
157 |
});
|
158 |
</script>
|
159 |
</body>
|