Create index.html
Browse files- index.html +57 -0
index.html
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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>Cygnis Image Gen</title>
|
| 7 |
+
<style>
|
| 8 |
+
body { font-family: sans-serif; background: #111; color: white; display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100vh; margin: 0; }
|
| 9 |
+
input { padding: 10px; width: 300px; border-radius: 5px; border: none; }
|
| 10 |
+
button { padding: 10px 20px; background: #8b5cf6; color: white; border: none; border-radius: 5px; cursor: pointer; margin-left: 10px; }
|
| 11 |
+
button:disabled { background: #555; }
|
| 12 |
+
#result { margin-top: 20px; max-width: 512px; }
|
| 13 |
+
img { width: 100%; border-radius: 10px; }
|
| 14 |
+
</style>
|
| 15 |
+
</head>
|
| 16 |
+
<body>
|
| 17 |
+
<h1>Cygnis Image Generator (DALL-E Mini)</h1>
|
| 18 |
+
<div>
|
| 19 |
+
<input type="text" id="prompt" placeholder="Un chat dans l'espace...">
|
| 20 |
+
<button id="btn">Générer</button>
|
| 21 |
+
</div>
|
| 22 |
+
<div id="result"></div>
|
| 23 |
+
|
| 24 |
+
<script>
|
| 25 |
+
const btn = document.getElementById('btn');
|
| 26 |
+
const prompt = document.getElementById('prompt');
|
| 27 |
+
const result = document.getElementById('result');
|
| 28 |
+
|
| 29 |
+
btn.addEventListener('click', async () => {
|
| 30 |
+
const text = prompt.value;
|
| 31 |
+
if (!text) return;
|
| 32 |
+
|
| 33 |
+
btn.disabled = true;
|
| 34 |
+
btn.textContent = "Génération...";
|
| 35 |
+
result.innerHTML = '<p>Calcul en cours (peut prendre 1-2 min sur CPU)...</p>';
|
| 36 |
+
|
| 37 |
+
try {
|
| 38 |
+
const res = await fetch('/generate', {
|
| 39 |
+
method: 'POST',
|
| 40 |
+
headers: { 'Content-Type': 'application/json' },
|
| 41 |
+
body: JSON.stringify({ prompt: text })
|
| 42 |
+
});
|
| 43 |
+
|
| 44 |
+
if (!res.ok) throw new Error("Erreur serveur");
|
| 45 |
+
const data = await res.json();
|
| 46 |
+
|
| 47 |
+
result.innerHTML = `<img src="${data.image_url}" alt="Image générée">`;
|
| 48 |
+
} catch (e) {
|
| 49 |
+
result.innerHTML = `<p style="color:red">Erreur: ${e.message}</p>`;
|
| 50 |
+
} finally {
|
| 51 |
+
btn.disabled = false;
|
| 52 |
+
btn.textContent = "Générer";
|
| 53 |
+
}
|
| 54 |
+
});
|
| 55 |
+
</script>
|
| 56 |
+
</body>
|
| 57 |
+
</html>
|