Spaces:
Running
Running
Update public/index.html
Browse files- public/index.html +26 -42
public/index.html
CHANGED
@@ -89,23 +89,23 @@
|
|
89 |
</div>
|
90 |
<div class="mb-6">
|
91 |
<button id="generateBtn" onclick="generateImage()" class="w-full px-8 py-3 bg-gradient-to-r from-neon-blue to-neon-purple rounded-full font-semibold hover:opacity-90 transition-opacity animate-glow">
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
<div id="loadingState" class="hidden text-center py-6">
|
96 |
<div class="inline-flex items-center space-x-4">
|
97 |
<div class="w-8 h-8 border-4 border-neon-blue border-t-transparent rounded-full animate-spin"></div>
|
98 |
<span class="text-neon-blue text-lg">Generating image...</span>
|
|
|
|
|
99 |
</div>
|
100 |
-
<div id="queueInfo" class="mt-4 text-gray-400"></div>
|
101 |
-
</div>
|
102 |
<div id="resultSection" class="hidden mt-8">
|
103 |
-
|
104 |
-
|
105 |
<div class="mt-6 flex justify-center">
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
</div>
|
110 |
</div>
|
111 |
</div>
|
@@ -156,13 +156,20 @@
|
|
156 |
}
|
157 |
hideResult();
|
158 |
showLoading(true);
|
159 |
-
if (model === 'heartsync') {
|
160 |
-
// SSE logic
|
|
|
|
|
|
|
|
|
|
|
161 |
try {
|
162 |
-
const
|
|
|
|
|
163 |
method: 'POST',
|
164 |
headers: { 'Content-Type': 'application/json' },
|
165 |
-
body: JSON.stringify(
|
166 |
});
|
167 |
const reader = response.body.getReader();
|
168 |
const decoder = new TextDecoder();
|
@@ -181,7 +188,11 @@
|
|
181 |
showLoading(true, 'Processing your image...');
|
182 |
} else if (data.type === 'success') {
|
183 |
showLoading(false);
|
184 |
-
|
|
|
|
|
|
|
|
|
185 |
return;
|
186 |
} else if (data.type === 'error') {
|
187 |
throw new Error(data.message);
|
@@ -194,33 +205,6 @@
|
|
194 |
showLoading(false);
|
195 |
alert('Generation failed: ' + error.message);
|
196 |
}
|
197 |
-
} else if (model === 'flux') {
|
198 |
-
// FLUX.1-dev JSON logic
|
199 |
-
const res = getFluxResolution();
|
200 |
-
width = res.width;
|
201 |
-
height = res.height;
|
202 |
-
try {
|
203 |
-
const response = await fetch('/api/generate/flux', {
|
204 |
-
method: 'POST',
|
205 |
-
headers: { 'Content-Type': 'application/json' },
|
206 |
-
body: JSON.stringify({ prompt, width, height })
|
207 |
-
});
|
208 |
-
const data = await response.json();
|
209 |
-
if (data.success && data.image && data.image.url) {
|
210 |
-
showLoading(false);
|
211 |
-
showResult(data.image.url);
|
212 |
-
} else if (data.success && typeof data.image === 'string') {
|
213 |
-
// fallback for string URL
|
214 |
-
showLoading(false);
|
215 |
-
showResult(data.image);
|
216 |
-
} else {
|
217 |
-
showLoading(false);
|
218 |
-
alert('Generation failed: ' + (data.error || 'Unknown error'));
|
219 |
-
}
|
220 |
-
} catch (error) {
|
221 |
-
showLoading(false);
|
222 |
-
alert('Generation failed: ' + error.message);
|
223 |
-
}
|
224 |
}
|
225 |
}
|
226 |
function downloadImage() {
|
|
|
89 |
</div>
|
90 |
<div class="mb-6">
|
91 |
<button id="generateBtn" onclick="generateImage()" class="w-full px-8 py-3 bg-gradient-to-r from-neon-blue to-neon-purple rounded-full font-semibold hover:opacity-90 transition-opacity animate-glow">
|
92 |
+
<i class="fas fa-magic mr-2"></i>Generate
|
93 |
+
</button>
|
94 |
+
</div>
|
95 |
<div id="loadingState" class="hidden text-center py-6">
|
96 |
<div class="inline-flex items-center space-x-4">
|
97 |
<div class="w-8 h-8 border-4 border-neon-blue border-t-transparent rounded-full animate-spin"></div>
|
98 |
<span class="text-neon-blue text-lg">Generating image...</span>
|
99 |
+
</div>
|
100 |
+
<div id="queueInfo" class="mt-4 text-gray-400"></div>
|
101 |
</div>
|
|
|
|
|
102 |
<div id="resultSection" class="hidden mt-8">
|
103 |
+
<div class="glass-effect rounded-2xl p-6 neon-border">
|
104 |
+
<img id="generatedImage" class="w-full rounded-xl shadow-2xl" alt="Generated image">
|
105 |
<div class="mt-6 flex justify-center">
|
106 |
+
<button onclick="downloadImage()" class="px-6 py-3 glass-effect rounded-full hover:neon-border transition-all">
|
107 |
+
<i class="fas fa-download mr-2"></i>Download
|
108 |
+
</button>
|
109 |
</div>
|
110 |
</div>
|
111 |
</div>
|
|
|
156 |
}
|
157 |
hideResult();
|
158 |
showLoading(true);
|
159 |
+
if (model === 'heartsync' || model === 'flux') {
|
160 |
+
// SSE logic for both models
|
161 |
+
if (model === 'flux') {
|
162 |
+
const res = getFluxResolution();
|
163 |
+
width = res.width;
|
164 |
+
height = res.height;
|
165 |
+
}
|
166 |
try {
|
167 |
+
const url = model === 'heartsync' ? '/api/generate' : '/api/generate/flux';
|
168 |
+
const body = model === 'heartsync' ? { prompt } : { prompt, width, height };
|
169 |
+
const response = await fetch(url, {
|
170 |
method: 'POST',
|
171 |
headers: { 'Content-Type': 'application/json' },
|
172 |
+
body: JSON.stringify(body)
|
173 |
});
|
174 |
const reader = response.body.getReader();
|
175 |
const decoder = new TextDecoder();
|
|
|
188 |
showLoading(true, 'Processing your image...');
|
189 |
} else if (data.type === 'success') {
|
190 |
showLoading(false);
|
191 |
+
if (model === 'flux') {
|
192 |
+
showResult(data.imageUrl);
|
193 |
+
} else {
|
194 |
+
showResult(data.originalUrl);
|
195 |
+
}
|
196 |
return;
|
197 |
} else if (data.type === 'error') {
|
198 |
throw new Error(data.message);
|
|
|
205 |
showLoading(false);
|
206 |
alert('Generation failed: ' + error.message);
|
207 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
208 |
}
|
209 |
}
|
210 |
function downloadImage() {
|