Update templates/index.html
Browse files- templates/index.html +174 -195
templates/index.html
CHANGED
@@ -1,207 +1,186 @@
|
|
1 |
<!DOCTYPE html>
|
2 |
<html lang="fr">
|
3 |
<head>
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
}
|
18 |
-
}
|
19 |
}
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
}
|
55 |
-
</style>
|
56 |
</head>
|
57 |
<body class="bg-gray-50 min-h-screen">
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
</div>
|
85 |
-
<div id="preview-container" class="mt-4 grid grid-cols-2 gap-4"></div>
|
86 |
-
</div>
|
87 |
-
|
88 |
-
<!-- Analysis Type Section -->
|
89 |
-
<div class="bg-white rounded-xl shadow-lg p-6">
|
90 |
-
<h2 class="text-2xl font-semibold text-primary mb-4">🎛️ Choix du type d'analyse</h2>
|
91 |
-
<div class="space-y-4">
|
92 |
-
<label class="flex items-center p-4 rounded-lg border border-gray-200 cursor-pointer hover:bg-gray-50 transition-colors">
|
93 |
-
<input type="radio" name="analysis_type" value="text" class="h-4 w-4 text-primary">
|
94 |
-
<span class="ml-3">🔍 Type 1: Analyse de Texte</span>
|
95 |
-
</label>
|
96 |
-
<label class="flex items-center p-4 rounded-lg border border-gray-200 cursor-pointer hover:bg-gray-50 transition-colors">
|
97 |
-
<input type="radio" name="analysis_type" value="icon" class="h-4 w-4 text-primary">
|
98 |
-
<span class="ml-3">🧠 Type 2: Document iconographique</span>
|
99 |
-
</label>
|
100 |
-
</div>
|
101 |
-
<button id="submit-btn" class="w-full mt-6 bg-primary hover:bg-primary-dark text-white font-bold py-3 px-6 rounded-lg transition-all transform hover:-translate-y-1 hover:shadow-lg disabled:opacity-50 disabled:cursor-not-allowed">
|
102 |
-
🚀 Soumettre
|
103 |
-
</button>
|
104 |
-
</div>
|
105 |
-
</div>
|
106 |
-
|
107 |
-
<!-- Results Section -->
|
108 |
-
<div id="results" class="mt-12 bg-white rounded-xl shadow-lg p-6 hidden">
|
109 |
-
<h2 class="text-2xl font-semibold text-primary mb-4">📝 Résultat de l'analyse</h2>
|
110 |
-
<div id="analysis-result" class="markdown-content prose max-w-none"></div>
|
111 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
112 |
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
</footer>
|
118 |
</div>
|
119 |
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
}
|
160 |
-
|
161 |
-
async function handleSubmit() {
|
162 |
-
if (uploadedFiles.length === 0) {
|
163 |
-
alert('Veuillez sélectionner au moins une image.');
|
164 |
-
return;
|
165 |
-
}
|
166 |
-
|
167 |
-
const analysisType = document.querySelector('input[name="analysis_type"]:checked')?.value;
|
168 |
-
if (!analysisType) {
|
169 |
-
alert('Veuillez sélectionner un type d\'analyse.');
|
170 |
-
return;
|
171 |
-
}
|
172 |
-
|
173 |
-
const formData = new FormData();
|
174 |
-
formData.append('analysis_type', analysisType);
|
175 |
-
uploadedFiles.forEach(file => formData.append('images', file));
|
176 |
-
|
177 |
-
submitBtn.disabled = true;
|
178 |
-
submitBtn.innerHTML = '<span class="animate-pulse">Analyse en cours...</span>';
|
179 |
-
|
180 |
-
try {
|
181 |
-
const response = await fetch('/analyze', {
|
182 |
-
method: 'POST',
|
183 |
-
body: formData
|
184 |
-
});
|
185 |
-
|
186 |
-
const data = await response.json();
|
187 |
-
|
188 |
-
if (data.error) {
|
189 |
-
throw new Error(data.error);
|
190 |
-
}
|
191 |
-
|
192 |
-
resultsSection.classList.remove('hidden');
|
193 |
-
analysisResult.innerHTML = marked.parse(data.result);
|
194 |
-
resultsSection.scrollIntoView({ behavior: 'smooth' });
|
195 |
-
} catch (error) {
|
196 |
-
alert('Erreur lors de l\'analyse: ' + error.message);
|
197 |
-
} finally {
|
198 |
-
submitBtn.disabled = false;
|
199 |
-
submitBtn.innerHTML = '🚀 Soumettre';
|
200 |
-
}
|
201 |
-
}
|
202 |
-
|
203 |
-
window.removeImage = removeImage;
|
204 |
});
|
205 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
206 |
</body>
|
207 |
-
</html>
|
|
|
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>Exercice de Philosophie</title>
|
7 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
8 |
+
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
|
9 |
+
<script>
|
10 |
+
tailwind.config = {
|
11 |
+
theme: {
|
12 |
+
extend: {
|
13 |
+
colors: {
|
14 |
+
primary: '#4CAF50',
|
15 |
+
'primary-dark': '#3e8e41',
|
16 |
+
}
|
|
|
|
|
17 |
}
|
18 |
+
}
|
19 |
+
}
|
20 |
+
</script>
|
21 |
+
<style>
|
22 |
+
.markdown-content {
|
23 |
+
width: 100%;
|
24 |
+
overflow-wrap: break-word;
|
25 |
+
word-wrap: break-word;
|
26 |
+
word-break: break-word;
|
27 |
+
hyphens: auto;
|
28 |
+
}
|
29 |
+
.markdown-content pre {
|
30 |
+
white-space: pre-wrap;
|
31 |
+
word-wrap: break-word;
|
32 |
+
padding: 1rem;
|
33 |
+
background-color: #f3f4f6;
|
34 |
+
border-radius: 0.5rem;
|
35 |
+
margin: 1rem 0;
|
36 |
+
overflow-x: auto;
|
37 |
+
}
|
38 |
+
.markdown-content code {
|
39 |
+
background-color: #f3f4f6;
|
40 |
+
padding: 0.2rem 0.4rem;
|
41 |
+
border-radius: 0.25rem;
|
42 |
+
font-family: ui-monospace, monospace;
|
43 |
+
}
|
44 |
+
@keyframes fadeIn {
|
45 |
+
from { opacity: 0; }
|
46 |
+
to { opacity: 1; }
|
47 |
+
}
|
48 |
+
.animate-fade-in {
|
49 |
+
animation: fadeIn 1s ease-out;
|
50 |
+
}
|
51 |
+
</style>
|
|
|
|
|
52 |
</head>
|
53 |
<body class="bg-gray-50 min-h-screen">
|
54 |
+
<div class="container mx-auto px-4 py-8 max-w-6xl">
|
55 |
+
<!-- Header -->
|
56 |
+
<header class="text-center mb-12 animate-fade-in">
|
57 |
+
<h1 class="text-5xl font-bold text-primary mb-4">
|
58 |
+
✨ Exercice de Philosophie ✨
|
59 |
+
</h1>
|
60 |
+
<p class="text-gray-600 text-lg">
|
61 |
+
Bienvenue ! Téléchargez vos images et laissez l'analyse philosophique opérer.
|
62 |
+
</p>
|
63 |
+
</header>
|
64 |
+
|
65 |
+
<!-- Main Content -->
|
66 |
+
<div class="grid md:grid-cols-2 gap-8">
|
67 |
+
<!-- Upload Section -->
|
68 |
+
<div class="bg-white rounded-xl shadow-lg p-6">
|
69 |
+
<h2 class="text-2xl font-semibold text-primary mb-4">📷 Téléchargement d'images</h2>
|
70 |
+
<div
|
71 |
+
class="upload-zone border-2 border-dashed border-primary rounded-lg p-8 text-center cursor-pointer hover:bg-gray-50 transition-colors"
|
72 |
+
onclick="document.getElementById('image-upload').click()">
|
73 |
+
<input type="file" id="image-upload" multiple accept="image/*" class="hidden">
|
74 |
+
<div class="flex flex-col items-center">
|
75 |
+
<svg class="h-12 w-12 text-primary mb-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
76 |
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4"></path>
|
77 |
+
</svg>
|
78 |
+
<span class="text-gray-600">Cliquez ou glissez vos images ici</span>
|
79 |
+
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
</div>
|
81 |
+
<div id="preview-container" class="mt-4 grid grid-cols-2 gap-4"></div>
|
82 |
+
</div>
|
83 |
+
|
84 |
+
<!-- Bouton de soumission (seulement) -->
|
85 |
+
<div class="bg-white rounded-xl shadow-lg p-6 flex flex-col justify-center">
|
86 |
+
<button id="submit-btn" class="w-full mt-6 bg-primary hover:bg-primary-dark text-white font-bold py-3 px-6 rounded-lg transition-all transform hover:-translate-y-1 hover:shadow-lg disabled:opacity-50 disabled:cursor-not-allowed">
|
87 |
+
🚀 Soumettre
|
88 |
+
</button>
|
89 |
+
</div>
|
90 |
+
</div>
|
91 |
|
92 |
+
<!-- Résultats -->
|
93 |
+
<div id="results" class="mt-12 bg-white rounded-xl shadow-lg p-6 hidden">
|
94 |
+
<h2 class="text-2xl font-semibold text-primary mb-4">📝 Résultat de l'analyse</h2>
|
95 |
+
<div id="analysis-result" class="markdown-content prose max-w-none"></div>
|
|
|
96 |
</div>
|
97 |
|
98 |
+
<!-- Footer -->
|
99 |
+
<footer class="mt-12 text-center text-gray-600">
|
100 |
+
<hr class="my-4">
|
101 |
+
<p>© 2025 Mariam AI - Tous droits réservés.</p>
|
102 |
+
</footer>
|
103 |
+
</div>
|
104 |
+
|
105 |
+
<script>
|
106 |
+
document.addEventListener('DOMContentLoaded', () => {
|
107 |
+
const imageUpload = document.getElementById('image-upload');
|
108 |
+
const previewContainer = document.getElementById('preview-container');
|
109 |
+
const submitBtn = document.getElementById('submit-btn');
|
110 |
+
const resultsSection = document.getElementById('results');
|
111 |
+
const analysisResult = document.getElementById('analysis-result');
|
112 |
+
|
113 |
+
let uploadedFiles = [];
|
114 |
+
|
115 |
+
imageUpload.addEventListener('change', handleFileSelect);
|
116 |
+
submitBtn.addEventListener('click', handleSubmit);
|
117 |
+
|
118 |
+
function handleFileSelect(event) {
|
119 |
+
uploadedFiles = Array.from(event.target.files);
|
120 |
+
updatePreview();
|
121 |
+
}
|
122 |
+
|
123 |
+
function updatePreview() {
|
124 |
+
previewContainer.innerHTML = '';
|
125 |
+
uploadedFiles.forEach((file, index) => {
|
126 |
+
const preview = document.createElement('div');
|
127 |
+
preview.className = 'relative';
|
128 |
+
preview.innerHTML = `
|
129 |
+
<img src="${URL.createObjectURL(file)}" alt="Preview" class="w-full h-32 object-cover rounded-lg">
|
130 |
+
<button onclick="removeImage(${index})" class="absolute top-2 right-2 bg-red-500 text-white rounded-full p-1 hover:bg-red-600">
|
131 |
+
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
132 |
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"></path>
|
133 |
+
</svg>
|
134 |
+
</button>
|
135 |
+
`;
|
136 |
+
previewContainer.appendChild(preview);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
137 |
});
|
138 |
+
submitBtn.disabled = uploadedFiles.length === 0;
|
139 |
+
}
|
140 |
+
|
141 |
+
function removeImage(index) {
|
142 |
+
uploadedFiles.splice(index, 1);
|
143 |
+
updatePreview();
|
144 |
+
}
|
145 |
+
|
146 |
+
async function handleSubmit() {
|
147 |
+
if (uploadedFiles.length === 0) {
|
148 |
+
alert('Veuillez sélectionner au moins une image.');
|
149 |
+
return;
|
150 |
+
}
|
151 |
+
|
152 |
+
const formData = new FormData();
|
153 |
+
// On n'envoie plus de type d'analyse, l'analyse est toujours philosophique.
|
154 |
+
uploadedFiles.forEach(file => formData.append('images', file));
|
155 |
+
|
156 |
+
submitBtn.disabled = true;
|
157 |
+
submitBtn.innerHTML = '<span class="animate-pulse">Analyse en cours...</span>';
|
158 |
+
|
159 |
+
try {
|
160 |
+
const response = await fetch('/analyze', {
|
161 |
+
method: 'POST',
|
162 |
+
body: formData
|
163 |
+
});
|
164 |
+
|
165 |
+
const data = await response.json();
|
166 |
+
|
167 |
+
if (data.error) {
|
168 |
+
throw new Error(data.error);
|
169 |
+
}
|
170 |
+
|
171 |
+
resultsSection.classList.remove('hidden');
|
172 |
+
analysisResult.innerHTML = marked.parse(data.result);
|
173 |
+
resultsSection.scrollIntoView({ behavior: 'smooth' });
|
174 |
+
} catch (error) {
|
175 |
+
alert('Erreur lors de l\'analyse: ' + error.message);
|
176 |
+
} finally {
|
177 |
+
submitBtn.disabled = false;
|
178 |
+
submitBtn.innerHTML = '🚀 Soumettre';
|
179 |
+
}
|
180 |
+
}
|
181 |
+
|
182 |
+
window.removeImage = removeImage;
|
183 |
+
});
|
184 |
+
</script>
|
185 |
</body>
|
186 |
+
</html>
|