Spaces:
Sleeping
Sleeping
Update templates/index.html
Browse files- templates/index.html +103 -90
templates/index.html
CHANGED
@@ -3,122 +3,135 @@
|
|
3 |
<head>
|
4 |
<meta charset="UTF-8">
|
5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
-
<title>
|
7 |
-
<script src="https://cdn.tailwindcss.com"></script>
|
8 |
<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
|
9 |
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
|
10 |
-
<
|
11 |
-
<
|
12 |
<style>
|
13 |
-
@
|
14 |
-
|
15 |
-
|
|
|
16 |
}
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
}
|
22 |
-
|
23 |
-
|
|
|
|
|
24 |
}
|
25 |
</style>
|
26 |
</head>
|
27 |
-
<body class="bg-gray-50">
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
<
|
35 |
-
<input type="file" name="image" id="image"
|
36 |
-
class="mt-1 block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
|
37 |
</div>
|
|
|
|
|
|
|
38 |
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
</
|
44 |
-
|
45 |
-
<button type="submit"
|
46 |
-
class="w-full flex justify-center py-2 px-4 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500">
|
47 |
-
Générer
|
48 |
-
</button>
|
49 |
-
</form>
|
50 |
-
|
51 |
-
<div id="loader" class="hidden">
|
52 |
-
<div class="custom-loader w-12 h-12 rounded-full mx-auto my-8"></div>
|
53 |
</div>
|
54 |
|
55 |
-
|
56 |
-
<div class="
|
57 |
-
<
|
58 |
-
<
|
59 |
-
|
60 |
-
|
|
|
61 |
</div>
|
62 |
-
|
|
|
|
|
63 |
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
<div class="relative mb-4 border border-gray-200 rounded-lg p-2">
|
68 |
-
<img src="{{ image_path }}" alt="Structure Chimique"
|
69 |
-
class="w-full rounded zoom-transition cursor-pointer hover:scale-105"
|
70 |
-
onclick="toggleZoomModal('{{ image_path }}')">
|
71 |
-
<button onclick="toggleZoomModal('{{ image_path }}')"
|
72 |
-
class="absolute top-2 right-2 bg-white/80 backdrop-blur-sm p-2 rounded-full shadow hover:bg-white">
|
73 |
-
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor">
|
74 |
-
<path d="M5 8a1 1 0 011-1h1V6a1 1 0 012 0v1h1a1 1 0 110 2H9v1a1 1 0 11-2 0V9H6a1 1 0 01-1-1z"/>
|
75 |
-
<path fill-rule="evenodd" d="M2 8a6 6 0 1110.89 3.476l4.817 4.817a1 1 0 01-1.414 1.414l-4.816-4.816A6 6 0 012 8zm6-4a4 4 0 100 8 4 4 0 000-8z" clip-rule="evenodd"/>
|
76 |
-
</svg>
|
77 |
-
</button>
|
78 |
-
</div>
|
79 |
-
{% endfor %}
|
80 |
-
</div>
|
81 |
</div>
|
82 |
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
|
|
|
|
|
|
90 |
</div>
|
91 |
-
{% endif %}
|
92 |
</div>
|
93 |
</div>
|
94 |
|
95 |
<script>
|
96 |
-
function
|
97 |
-
|
98 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
99 |
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
modal.classList.remove('hidden');
|
104 |
-
zoomedImage.src = imagePath;
|
105 |
-
document.body.style.overflow = 'hidden';
|
106 |
-
}
|
107 |
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
112 |
|
113 |
-
|
114 |
-
|
115 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
116 |
}
|
117 |
});
|
118 |
-
|
119 |
-
window.onload = function() {
|
120 |
-
document.getElementById('loader').classList.add('hidden');
|
121 |
-
};
|
122 |
</script>
|
123 |
</body>
|
124 |
</html>
|
|
|
3 |
<head>
|
4 |
<meta charset="UTF-8">
|
5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
+
<title>Mariam AI - Résolution d'exercices Physique-Chimie</title>
|
|
|
7 |
<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
|
8 |
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
|
9 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
10 |
+
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
|
11 |
<style>
|
12 |
+
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');
|
13 |
+
|
14 |
+
body {
|
15 |
+
font-family: 'Poppins', sans-serif;
|
16 |
}
|
17 |
+
|
18 |
+
.loader {
|
19 |
+
width: 48px;
|
20 |
+
height: 48px;
|
21 |
+
border: 5px solid #FFF;
|
22 |
+
border-bottom-color: #3B82F6;
|
23 |
+
border-radius: 50%;
|
24 |
+
display: inline-block;
|
25 |
+
box-sizing: border-box;
|
26 |
+
animation: rotation 1s linear infinite;
|
27 |
}
|
28 |
+
|
29 |
+
@keyframes rotation {
|
30 |
+
0% { transform: rotate(0deg); }
|
31 |
+
100% { transform: rotate(360deg); }
|
32 |
}
|
33 |
</style>
|
34 |
</head>
|
35 |
+
<body class="bg-gray-50 min-h-screen">
|
36 |
+
<!-- Navbar -->
|
37 |
+
<nav class="bg-white shadow-lg">
|
38 |
+
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
|
39 |
+
<div class="flex justify-between items-center h-16">
|
40 |
+
<div class="flex items-center">
|
41 |
+
<i class="fas fa-atom text-blue-600 text-2xl mr-2"></i>
|
42 |
+
<span class="font-bold text-xl text-gray-800">Mariam AI</span>
|
|
|
|
|
43 |
</div>
|
44 |
+
</div>
|
45 |
+
</div>
|
46 |
+
</nav>
|
47 |
|
48 |
+
<!-- Main Content -->
|
49 |
+
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
|
50 |
+
<div class="bg-white rounded-lg shadow-xl p-6 md:p-8">
|
51 |
+
<div class="text-center mb-8">
|
52 |
+
<h1 class="text-3xl font-bold text-gray-800 mb-2">Assistant Physique-Chimie</h1>
|
53 |
+
<p class="text-gray-600">Uploadez une photo de votre exercice pour obtenir une résolution détaillée</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
</div>
|
55 |
|
56 |
+
<!-- Upload Section -->
|
57 |
+
<div class="flex flex-col items-center justify-center w-full">
|
58 |
+
<label for="image-input" class="flex flex-col items-center justify-center w-full h-64 border-2 border-blue-300 border-dashed rounded-lg cursor-pointer bg-gray-50 hover:bg-gray-100 transition duration-300">
|
59 |
+
<div class="flex flex-col items-center justify-center pt-5 pb-6">
|
60 |
+
<i class="fas fa-cloud-upload-alt text-4xl text-blue-500 mb-4"></i>
|
61 |
+
<p class="mb-2 text-sm text-gray-500"><span class="font-semibold">Cliquez pour upload</span> ou glissez-déposez</p>
|
62 |
+
<p class="text-xs text-gray-500">PNG, JPG ou JPEG</p>
|
63 |
</div>
|
64 |
+
<input id="image-input" type="file" class="hidden" accept="image/*" />
|
65 |
+
</label>
|
66 |
+
</div>
|
67 |
|
68 |
+
<!-- Preview Section -->
|
69 |
+
<div class="mt-8">
|
70 |
+
<img id="image-preview" class="max-w-full h-auto mx-auto rounded-lg shadow-md hidden" alt="Preview">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
</div>
|
72 |
|
73 |
+
<!-- Loading Animation -->
|
74 |
+
<div id="loading" class="hidden flex justify-center items-center my-8">
|
75 |
+
<span class="loader"></span>
|
76 |
+
<span class="ml-3 text-gray-600">Analyse en cours...</span>
|
77 |
+
</div>
|
78 |
+
|
79 |
+
<!-- Result Section -->
|
80 |
+
<div id="result-container" class="hidden mt-8">
|
81 |
+
<h2 class="text-xl font-semibold text-gray-800 mb-4">Résolution détaillée :</h2>
|
82 |
+
<div id="result" class="bg-gray-50 rounded-lg p-6 prose max-w-none"></div>
|
83 |
</div>
|
|
|
84 |
</div>
|
85 |
</div>
|
86 |
|
87 |
<script>
|
88 |
+
document.getElementById('image-input').addEventListener('change', async function(e) {
|
89 |
+
const file = e.target.files[0];
|
90 |
+
if (file) {
|
91 |
+
// Show preview
|
92 |
+
const preview = document.getElementById('image-preview');
|
93 |
+
const reader = new FileReader();
|
94 |
+
reader.onload = function(e) {
|
95 |
+
preview.src = e.target.result;
|
96 |
+
preview.classList.remove('hidden');
|
97 |
+
};
|
98 |
+
reader.readAsDataURL(file);
|
99 |
|
100 |
+
// Show loading
|
101 |
+
document.getElementById('loading').classList.remove('hidden');
|
102 |
+
document.getElementById('result-container').classList.add('hidden');
|
|
|
|
|
|
|
|
|
103 |
|
104 |
+
try {
|
105 |
+
const response = await fetch('/generate', {
|
106 |
+
method: 'POST',
|
107 |
+
headers: {
|
108 |
+
'Content-Type': 'application/json',
|
109 |
+
},
|
110 |
+
body: JSON.stringify({
|
111 |
+
image: await new Promise(resolve => {
|
112 |
+
reader.onload = () => resolve(reader.result);
|
113 |
+
reader.readAsDataURL(file);
|
114 |
+
})
|
115 |
+
})
|
116 |
+
});
|
117 |
|
118 |
+
const data = await response.json();
|
119 |
+
|
120 |
+
// Hide loading
|
121 |
+
document.getElementById('loading').classList.add('hidden');
|
122 |
+
|
123 |
+
// Show result
|
124 |
+
document.getElementById('result-container').classList.remove('hidden');
|
125 |
+
document.getElementById('result').innerHTML = data.result;
|
126 |
+
MathJax.typeset();
|
127 |
+
} catch (error) {
|
128 |
+
console.error('Erreur:', error);
|
129 |
+
// Hide loading
|
130 |
+
document.getElementById('loading').classList.add('hidden');
|
131 |
+
alert('Une erreur est survenue lors du traitement de l\'image.');
|
132 |
+
}
|
133 |
}
|
134 |
});
|
|
|
|
|
|
|
|
|
135 |
</script>
|
136 |
</body>
|
137 |
</html>
|