TextToImage / index.html
adminuser742150's picture
Update index.html
32476aa verified
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>DALL·E Mini Generator</title>
<style>
body {
margin: 0;
padding: 0;
font-family: "Source Sans Pro", sans-serif;
background: linear-gradient(135deg, #ece9f7 0%, #d4f1f9 100%);
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
}
.container {
background: #fff;
border-radius: 16px;
padding: 2rem;
box-shadow: 0 6px 30px rgba(0, 0, 0, 0.1);
max-width: 700px;
width: 100%;
text-align: center;
}
h1 {
margin-bottom: 0.5rem;
font-size: 1.8rem;
color: #333;
}
p {
margin-bottom: 1.5rem;
font-size: 1rem;
color: #666;
}
input {
width: 100%;
padding: 0.8rem 1rem;
border-radius: 10px;
border: 1px solid #ddd;
margin-bottom: 1rem;
font-size: 1rem;
background: #fafafa;
}
input:focus {
outline: none;
border-color: #7b61ff;
box-shadow: 0 0 0 2px rgba(123, 97, 255, 0.2);
}
button {
background: linear-gradient(90deg, #7b61ff, #5eead4);
border: none;
color: white;
font-size: 1rem;
font-weight: 600;
padding: 0.8rem 1.6rem;
border-radius: 10px;
cursor: pointer;
transition: 0.2s ease;
}
button:hover {
transform: translateY(-2px);
background: linear-gradient(90deg, #5eead4, #7b61ff);
}
.gallery {
margin-top: 1.5rem;
display: grid;
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
gap: 1rem;
}
.gallery img {
width: 100%;
border-radius: 12px;
box-shadow: 0 2px 10px rgba(0,0,0,0.08);
background: #f9f9f9;
}
</style>
</head>
<body>
<div class="container">
<h1>🎨 DALL·E Mini Generator</h1>
<p>Generate AI-powered images from any text prompt.</p>
<input id="prompt" type="text" placeholder="Enter your prompt here..." />
<button onclick="generateImages()">Generate</button>
<div id="gallery" class="gallery"></div>
</div>
<script>
async function generateImages() {
const prompt = document.getElementById("prompt").value.trim();
const gallery = document.getElementById("gallery");
if (!prompt) {
alert("Please enter a prompt first!");
return;
}
gallery.innerHTML = "<p>⏳ Generating images...</p>";
try {
const response = await fetch("https://bf.dallemini.ai/generate", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Accept": "application/json",
},
body: JSON.stringify({ prompt }),
});
const data = await response.json();
gallery.innerHTML = "";
data.images.forEach(imgBase64 => {
const img = document.createElement("img");
img.src = "data:image/png;base64," + imgBase64;
gallery.appendChild(img);
});
} catch (error) {
console.error(error);
gallery.innerHTML = "<p>⚠️ Error: Too much traffic, try again later.</p>";
}
}
</script>
</body>
</html>