Diwashbarla commited on
Commit
c2b6f10
·
verified ·
1 Parent(s): 9247d0e

Update templates/index.html

Browse files
Files changed (1) hide show
  1. 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 Vision Pro</title>
7
  <script src="https://cdn.tailwindcss.com"></script>
 
8
  <script src="https://unpkg.com"></script>
9
  <style>
10
- .loading-ring { border: 4px solid #f3f3f3; border-top: 4px solid #3b82f6; border-radius: 50%; width: 40px; height: 40px; animation: spin 1s linear infinite; }
11
- @keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
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-[#020617] text-slate-200 min-h-screen flex items-center justify-center p-6">
16
 
17
- <div class="glass max-w-2xl w-full p-8 rounded-[2rem] shadow-2xl">
18
- <h1 class="text-3xl font-black text-center mb-8 bg-gradient-to-r from-cyan-400 to-blue-600 bg-clip-text text-transparent">AI IMAGE STUDIO</h1>
 
 
19
 
20
- <div class="space-y-5">
21
- <!-- Prompt Area with Enhance Icon -->
 
 
 
22
  <div class="relative">
23
- <label class="text-xs font-bold text-slate-500 ml-1 uppercase">Positive Prompt</label>
24
- <textarea id="prompt" class="w-full bg-slate-900/50 border border-slate-700 rounded-2xl p-4 pr-12 focus:border-blue-500 outline-none transition-all" rows="3"></textarea>
25
- <button onclick="enhancePrompt()" class="absolute right-4 bottom-4 text-slate-400 hover:text-cyan-400 transition-colors" title="Enhance Prompt">
26
- <i data-lucide="sparkles"></i>
27
  </button>
28
  </div>
29
 
30
- <!-- Negative Prompt -->
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-900 border border-slate-700 rounded-xl p-3 outline-none">
39
  <option value="1024/1024">1:1 Square</option>
40
- <option value="1280/720">16:9 Cinema</option>
41
- <option value="720/1280">9:16 Portrait</option>
42
  </select>
43
- <select id="model" class="bg-slate-900 border border-slate-700 rounded-xl p-3 outline-none">
44
- <option value="flux">Flux (High Quality)</option>
45
  <option value="turbo">Turbo (Fast)</option>
46
  </select>
47
  </div>
48
 
49
- <button onclick="generate()" id="genBtn" 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 shadow-lg shadow-blue-900/20">
50
- <i data-lucide="wand-2" id="btnIcon"></i> <span id="btnText">Generate Magic</span>
51
  </button>
52
  </div>
53
 
54
- <!-- Output Animation & Image -->
55
- <div class="mt-8 relative group">
56
- <div id="loader" class="hidden absolute inset-0 flex flex-col items-center justify-center bg-slate-900/80 rounded-2xl z-10">
57
- <div class="loading-ring mb-4"></div>
58
- <p class="text-cyan-400 font-medium animate-pulse">Dreaming up your image...</p>
 
 
 
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 enhancePrompt() {
74
- const p = document.getElementById('prompt');
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
- const negative = document.getElementById('negative').value;
86
- const [w, h] = document.getElementById('ratio').value.split('/');
87
- const model = document.getElementById('model').value;
88
 
89
- if(!prompt) return;
 
 
 
 
90
 
91
- // Start UI
92
- loader.classList.remove('hidden');
93
- output.classList.add('hidden');
94
- dlBtn.classList.add('hidden');
95
  btn.disabled = true;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96
 
97
- const res = await fetch('/generate', {
98
- method: 'POST',
99
- headers: {'Content-Type': 'application/json'},
100
- body: JSON.stringify({ prompt, negative, width: w, height: h, model })
101
- });
102
- const data = await res.json();
103
-
104
- output.src = data.url;
105
- output.onload = () => {
106
- loader.classList.add('hidden');
107
- output.classList.remove('hidden');
108
- dlBtn.classList.remove('hidden');
109
  btn.disabled = false;
110
- };
111
  }
112
 
113
- function downloadImg() {
114
- const url = document.getElementById('output').src;
115
- const a = document.createElement('a');
116
- a.href = url;
117
- a.download = 'ai-image.png';
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>