Docfile commited on
Commit
49935aa
·
verified ·
1 Parent(s): 04084ef

Update templates/index.html

Browse files
Files changed (1) hide show
  1. 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>Générateur de contenu avec Gemini et RDKit</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
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css">
11
- <script src="https://cdn.jsdelivr.net/npm/marked@4.0.0/marked.min.js"></script>
12
  <style>
13
- @keyframes spin {
14
- 0% { transform: rotate(0deg); }
15
- 100% { transform: rotate(360deg); }
 
16
  }
17
- .custom-loader {
18
- border: 3px solid #e5e7eb;
19
- border-top: 3px solid #3b82f6;
20
- animation: spin 1s linear infinite;
 
 
 
 
 
 
21
  }
22
- .zoom-transition {
23
- transition: all 0.3s ease-in-out;
 
 
24
  }
25
  </style>
26
  </head>
27
- <body class="bg-gray-50">
28
- <div class="min-h-screen p-6">
29
- <div class="max-w-7xl mx-auto">
30
- <h1 class="text-3xl font-bold text-gray-900 mb-8">Générateur de contenu avec Gemini et RDKit</h1>
31
-
32
- <form method="POST" enctype="multipart/form-data" onsubmit="showLoader()" class="space-y-6 bg-white p-6 rounded-lg shadow-sm">
33
- <div>
34
- <label for="image" class="block text-sm font-medium text-gray-700">Image</label>
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
- <div>
40
- <label for="text_input" class="block text-sm font-medium text-gray-700">Texte</label>
41
- <textarea name="text_input" id="text_input" rows="4"
42
- 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"></textarea>
43
- </div>
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
- {% if generated_content %}
56
- <div class="mt-8 grid grid-cols-1 md:grid-cols-3 gap-6">
57
- <div class="md:col-span-2 bg-white p-6 rounded-lg shadow-sm">
58
- <h2 class="text-xl font-semibold text-gray-900 mb-4">Contenu généré</h2>
59
- <div class="prose max-w-none">
60
- {{ generated_content | safe }}
 
61
  </div>
62
- </div>
 
 
63
 
64
- <div class="bg-white p-6 rounded-lg shadow-sm">
65
- <h2 class="text-xl font-semibold text-gray-900 mb-4">Structures chimiques</h2>
66
- {% for image_path in image_paths %}
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
- <div id="zoomModal" class="hidden fixed inset-0 bg-black bg-opacity-90 z-50 flex items-center justify-center">
84
- <button onclick="closeZoomModal()" class="absolute top-4 right-4 text-white hover:text-gray-300">
85
- <svg xmlns="http://www.w3.org/2000/svg" class="h-8 w-8" fill="none" viewBox="0 0 24 24" stroke="currentColor">
86
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"/>
87
- </svg>
88
- </button>
89
- <img id="zoomedImage" src="" class="max-w-[90%] max-h-[90vh] object-contain">
 
 
 
90
  </div>
91
- {% endif %}
92
  </div>
93
  </div>
94
 
95
  <script>
96
- function showLoader() {
97
- document.getElementById('loader').classList.remove('hidden');
98
- }
 
 
 
 
 
 
 
 
99
 
100
- function toggleZoomModal(imagePath) {
101
- const modal = document.getElementById('zoomModal');
102
- const zoomedImage = document.getElementById('zoomedImage');
103
- modal.classList.remove('hidden');
104
- zoomedImage.src = imagePath;
105
- document.body.style.overflow = 'hidden';
106
- }
107
 
108
- function closeZoomModal() {
109
- document.getElementById('zoomModal').classList.add('hidden');
110
- document.body.style.overflow = 'auto';
111
- }
 
 
 
 
 
 
 
 
 
112
 
113
- document.getElementById('zoomModal').addEventListener('click', function(event) {
114
- if (event.target === this) {
115
- closeZoomModal();
 
 
 
 
 
 
 
 
 
 
 
 
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>