Spaces:
Sleeping
Sleeping
Update templates/index.html
Browse files- templates/index.html +78 -75
templates/index.html
CHANGED
|
@@ -3,121 +3,124 @@
|
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
-
<title>AI
|
| 7 |
<script src="https://cdn.tailwindcss.com"></script>
|
|
|
|
| 8 |
<script src="https://unpkg.com"></script>
|
| 9 |
<style>
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
.glass { background: rgba(15, 23, 42, 0.8); backdrop-filter: blur(12px); border: 1px solid rgba(255,255,255,0.1); }
|
| 13 |
</style>
|
| 14 |
</head>
|
| 15 |
-
<body class="bg-
|
| 16 |
|
| 17 |
-
<div class="
|
| 18 |
-
|
|
|
|
|
|
|
| 19 |
|
| 20 |
-
<
|
| 21 |
-
<
|
|
|
|
|
|
|
|
|
|
| 22 |
<div class="relative">
|
| 23 |
-
<
|
| 24 |
-
<
|
| 25 |
-
<button onclick="
|
| 26 |
-
<i data-lucide="
|
| 27 |
</button>
|
| 28 |
</div>
|
| 29 |
|
| 30 |
-
<
|
| 31 |
-
<div>
|
| 32 |
-
<label class="text-xs font-bold text-slate-500 ml-1 uppercase">Negative Prompt (क्या नहीं चाहिए)</label>
|
| 33 |
-
<input id="negative" type="text" class="w-full bg-slate-900/50 border border-slate-700 rounded-xl p-3 focus:border-red-500 outline-none" placeholder="blur, distorted, low quality...">
|
| 34 |
-
</div>
|
| 35 |
|
| 36 |
-
<!-- Options -->
|
| 37 |
<div class="grid grid-cols-2 gap-4">
|
| 38 |
-
<select id="ratio" class="bg-slate-
|
| 39 |
<option value="1024/1024">1:1 Square</option>
|
| 40 |
-
<option value="1280/720">16:9
|
| 41 |
-
<option value="720/1280">9:16 Portrait</option>
|
| 42 |
</select>
|
| 43 |
-
<select id="model" class="bg-slate-
|
| 44 |
-
<option value="flux">Flux (
|
| 45 |
<option value="turbo">Turbo (Fast)</option>
|
| 46 |
</select>
|
| 47 |
</div>
|
| 48 |
|
| 49 |
-
<button onclick="generate()" id="
|
| 50 |
-
<i data-lucide="
|
| 51 |
</button>
|
| 52 |
</div>
|
| 53 |
|
| 54 |
-
<!--
|
| 55 |
-
<div class="mt-
|
| 56 |
-
<div id="
|
| 57 |
-
|
| 58 |
-
<
|
|
|
|
|
|
|
|
|
|
| 59 |
</div>
|
| 60 |
-
|
| 61 |
-
<img id="output" class="w-full rounded-2xl hidden shadow-2xl border border-slate-700">
|
| 62 |
-
|
| 63 |
-
<!-- Download Button -->
|
| 64 |
-
<button id="dlBtn" onclick="downloadImg()" class="hidden absolute top-4 right-4 bg-black/50 hover:bg-black p-3 rounded-full backdrop-blur-md transition-all">
|
| 65 |
-
<i data-lucide="download" class="w-5 h-5"></i>
|
| 66 |
-
</button>
|
| 67 |
</div>
|
| 68 |
</div>
|
| 69 |
|
| 70 |
<script>
|
|
|
|
| 71 |
lucide.createIcons();
|
| 72 |
|
| 73 |
-
function
|
| 74 |
-
|
| 75 |
-
p.value += ", highly detailed, 8k, masterpiece, cinematic lighting";
|
| 76 |
}
|
| 77 |
|
| 78 |
async function generate() {
|
| 79 |
-
const btn = document.getElementById('genBtn');
|
| 80 |
-
const loader = document.getElementById('loader');
|
| 81 |
-
const output = document.getElementById('output');
|
| 82 |
-
const dlBtn = document.getElementById('dlBtn');
|
| 83 |
-
|
| 84 |
const prompt = document.getElementById('prompt').value;
|
| 85 |
-
|
| 86 |
-
const [w, h] = document.getElementById('ratio').value.split('/');
|
| 87 |
-
const model = document.getElementById('model').value;
|
| 88 |
|
| 89 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
|
| 91 |
-
//
|
| 92 |
-
loader.classList.remove('hidden');
|
| 93 |
-
output.classList.add('hidden');
|
| 94 |
-
dlBtn.classList.add('hidden');
|
| 95 |
btn.disabled = true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 96 |
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
btn.disabled = false;
|
| 110 |
-
}
|
| 111 |
}
|
| 112 |
|
| 113 |
-
function
|
| 114 |
-
const
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
document.body.appendChild(a);
|
| 119 |
-
a.click();
|
| 120 |
-
document.body.removeChild(a);
|
| 121 |
}
|
| 122 |
</script>
|
| 123 |
</body>
|
|
|
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>AI Studio Pro</title>
|
| 7 |
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
+
<!-- Lucide Icons के लिए सही CDN -->
|
| 9 |
<script src="https://unpkg.com"></script>
|
| 10 |
<style>
|
| 11 |
+
@keyframes progress { 0% { width: 0%; } 100% { width: 100%; } }
|
| 12 |
+
.loading-bar { height: 4px; background: #3b82f6; animation: progress 15s linear infinite; }
|
|
|
|
| 13 |
</style>
|
| 14 |
</head>
|
| 15 |
+
<body class="bg-slate-950 text-white min-h-screen flex items-center justify-center p-4">
|
| 16 |
|
| 17 |
+
<div class="max-w-xl w-full bg-slate-900 border border-slate-800 p-8 rounded-[2.5rem] shadow-2xl relative overflow-hidden">
|
| 18 |
+
|
| 19 |
+
<!-- Loading Animation Bar -->
|
| 20 |
+
<div id="pBar" class="absolute top-0 left-0 hidden w-full"><div class="loading-bar"></div></div>
|
| 21 |
|
| 22 |
+
<h2 class="text-2xl font-black mb-6 text-blue-400 flex items-center gap-2">
|
| 23 |
+
<i data-lucide="sparkles"></i> AI Image Lab
|
| 24 |
+
</h2>
|
| 25 |
+
|
| 26 |
+
<div class="space-y-4">
|
| 27 |
<div class="relative">
|
| 28 |
+
<textarea id="prompt" class="w-full bg-slate-800 border border-slate-700 rounded-2xl p-4 pr-12 focus:ring-2 focus:ring-blue-500 outline-none" placeholder="आपका प्रॉम्प्ट यहाँ लिखें..."></textarea>
|
| 29 |
+
<!-- Enhance Icon -->
|
| 30 |
+
<button onclick="enhance()" class="absolute right-4 bottom-4 text-blue-500 hover:scale-110 transition-transform">
|
| 31 |
+
<i data-lucide="wand-2"></i>
|
| 32 |
</button>
|
| 33 |
</div>
|
| 34 |
|
| 35 |
+
<input id="negative" type="text" class="w-full bg-slate-800 border border-slate-700 rounded-xl p-3 text-sm" placeholder="Negative Prompt (e.g. blur, text)">
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
|
|
|
| 37 |
<div class="grid grid-cols-2 gap-4">
|
| 38 |
+
<select id="ratio" class="bg-slate-800 p-3 rounded-xl border border-slate-700">
|
| 39 |
<option value="1024/1024">1:1 Square</option>
|
| 40 |
+
<option value="1280/720">16:9 Wide</option>
|
|
|
|
| 41 |
</select>
|
| 42 |
+
<select id="model" class="bg-slate-800 p-3 rounded-xl border border-slate-700">
|
| 43 |
+
<option value="flux">Flux (HD)</option>
|
| 44 |
<option value="turbo">Turbo (Fast)</option>
|
| 45 |
</select>
|
| 46 |
</div>
|
| 47 |
|
| 48 |
+
<button onclick="generate()" id="btn" class="w-full bg-blue-600 hover:bg-blue-500 py-4 rounded-2xl font-bold flex items-center justify-center gap-2 transition-all">
|
| 49 |
+
<i data-lucide="zap"></i> Generate Image
|
| 50 |
</button>
|
| 51 |
</div>
|
| 52 |
|
| 53 |
+
<!-- Result Area -->
|
| 54 |
+
<div class="mt-6">
|
| 55 |
+
<div id="status" class="text-center text-sm text-slate-500 mb-2 hidden">इमेज तैयार हो रही है, कृपया 10-15 सेकंड रुकें...</div>
|
| 56 |
+
<div id="box" class="rounded-2xl overflow-hidden border border-slate-800 min-h-[200px] flex items-center justify-center bg-slate-950 relative">
|
| 57 |
+
<img id="output" class="hidden w-full">
|
| 58 |
+
<button id="dl" onclick="download()" class="hidden absolute bottom-4 right-4 bg-white/10 p-2 rounded-full backdrop-blur-md">
|
| 59 |
+
<i data-lucide="download"></i>
|
| 60 |
+
</button>
|
| 61 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
</div>
|
| 63 |
</div>
|
| 64 |
|
| 65 |
<script>
|
| 66 |
+
// आइकन्स लोड करें
|
| 67 |
lucide.createIcons();
|
| 68 |
|
| 69 |
+
function enhance() {
|
| 70 |
+
document.getElementById('prompt').value += ", highly detailed, cinematic lighting, 8k resolution, photorealistic";
|
|
|
|
| 71 |
}
|
| 72 |
|
| 73 |
async function generate() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
const prompt = document.getElementById('prompt').value;
|
| 75 |
+
if(!prompt) return alert("प्रॉम्प्ट खाली है!");
|
|
|
|
|
|
|
| 76 |
|
| 77 |
+
const btn = document.getElementById('btn');
|
| 78 |
+
const pBar = document.getElementById('pBar');
|
| 79 |
+
const status = document.getElementById('status');
|
| 80 |
+
const output = document.getElementById('output');
|
| 81 |
+
const dl = document.getElementById('dl');
|
| 82 |
|
| 83 |
+
// UI Reset
|
|
|
|
|
|
|
|
|
|
| 84 |
btn.disabled = true;
|
| 85 |
+
btn.innerText = "Processing...";
|
| 86 |
+
pBar.classList.remove('hidden');
|
| 87 |
+
status.classList.remove('hidden');
|
| 88 |
+
output.classList.add('hidden');
|
| 89 |
+
dl.classList.add('hidden');
|
| 90 |
+
|
| 91 |
+
try {
|
| 92 |
+
const [w, h] = document.getElementById('ratio').value.split('/');
|
| 93 |
+
const model = document.getElementById('model').value;
|
| 94 |
+
const neg = document.getElementById('negative').value;
|
| 95 |
+
|
| 96 |
+
const res = await fetch('/generate', {
|
| 97 |
+
method: 'POST',
|
| 98 |
+
headers: {'Content-Type': 'application/json'},
|
| 99 |
+
body: JSON.stringify({ prompt: encodeURIComponent(prompt), width: w, height: h, model, negative: neg })
|
| 100 |
+
});
|
| 101 |
+
const data = await res.json();
|
| 102 |
|
| 103 |
+
// इमेज लोड होने का इंतज़ार
|
| 104 |
+
output.src = data.url;
|
| 105 |
+
output.onload = () => {
|
| 106 |
+
output.classList.remove('hidden');
|
| 107 |
+
dl.classList.remove('hidden');
|
| 108 |
+
pBar.classList.add('hidden');
|
| 109 |
+
status.classList.add('hidden');
|
| 110 |
+
btn.disabled = false;
|
| 111 |
+
btn.innerText = "Generate Image";
|
| 112 |
+
};
|
| 113 |
+
} catch (e) {
|
| 114 |
+
alert("सर्वर में समस्या है!");
|
| 115 |
btn.disabled = false;
|
| 116 |
+
}
|
| 117 |
}
|
| 118 |
|
| 119 |
+
function download() {
|
| 120 |
+
const link = document.createElement('a');
|
| 121 |
+
link.href = document.getElementById('output').src;
|
| 122 |
+
link.download = 'ai_image.png';
|
| 123 |
+
link.click();
|
|
|
|
|
|
|
|
|
|
| 124 |
}
|
| 125 |
</script>
|
| 126 |
</body>
|