File size: 20,791 Bytes
b191b72
 
7977b25
 
bf705f0
eb8bfcc
 
 
 
9d3234f
eb8bfcc
b191b72
 
7977b25
5da16a1
d498116
bf705f0
 
752ebc6
bf705f0
 
 
752ebc6
d498116
afcfedc
d498116
d9b28b7
 
 
 
 
d498116
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
afcfedc
4bde23f
9d3234f
 
 
 
 
 
 
 
 
 
 
 
 
 
d498116
 
 
4bde23f
 
d498116
 
4bde23f
d498116
847827f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1141c49
4bde23f
9d3234f
 
 
 
4bde23f
9d3234f
 
 
 
eb8bfcc
9d3234f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d498116
7977b25
d498116
 
 
 
 
4bde23f
 
 
 
 
 
9d3234f
d498116
 
 
 
 
4bde23f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d498116
4bde23f
d498116
eb8bfcc
 
4bde23f
2b57bf6
eb8bfcc
4bde23f
eb8bfcc
bf705f0
 
 
 
 
 
 
 
7977b25
bf705f0
 
9d3234f
 
 
 
 
 
 
bf705f0
d498116
bf705f0
 
d498116
4bde23f
 
d498116
e831e8e
b191b72
 
 
bf705f0
b191b72
bf705f0
 
 
 
eb8bfcc
618b16c
9d3234f
 
 
d498116
9d3234f
 
 
 
 
d498116
 
 
 
9d3234f
 
 
 
 
 
4bde23f
d498116
4bde23f
eb8bfcc
9d3234f
 
bf705f0
 
b191b72
9d3234f
eb8bfcc
 
d498116
 
9d3234f
eb8bfcc
 
9d3234f
 
 
 
 
 
 
 
 
 
 
 
 
4bde23f
9d3234f
 
facdc29
 
 
 
4bde23f
d498116
9d3234f
d498116
 
9d3234f
 
 
 
 
 
4bde23f
 
 
 
 
d498116
9d3234f
4bde23f
 
 
 
d498116
 
9d3234f
4bde23f
 
 
9d3234f
 
 
 
 
 
 
 
 
 
 
 
 
 
4bde23f
9d3234f
b633db3
9d3234f
 
 
 
 
 
 
 
 
 
 
 
 
 
4bde23f
 
d498116
4bde23f
 
 
d498116
4bde23f
 
 
 
 
d498116
4bde23f
 
 
 
 
 
 
eb8bfcc
facdc29
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
from flask import Flask, request, jsonify
import requests
import threading
import time
from datetime import datetime
import os

# โญ AI KEYS
GROQ_KEY = "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"
OPENROUTER_KEY = "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"
os.environ["GROQ_API_KEY"] = GROQ_KEY

app = Flask(__name__)
VERCEL = "https://ai-ivory-delta.vercel.app"

stats = {"sites": 0, "deployed": 0, "started": datetime.now().isoformat()}
logs = []
running = False

def add_log(msg):
    logs.append(f"[{datetime.now().strftime('%H:%M:%S')}] {msg}")
    if len(logs) > 50: logs.pop(0)

def call_best_ai(prompt):
    """Try ALL free models via OpenRouter"""
    models = [
    ("google/gemini-2.0-flash-001", "Gemini"),
    ("anthropic/claude-3-haiku", "Claude"),
    ("deepseek/deepseek-r1", "DeepSeek"),
    ("meta-llama/llama-3.3-70b-instruct", "Llama"),
    ("mistralai/mistral-7b-instruct", "Mistral"),
    ]
    for model_id, name in models:
        try:
            r = requests.post("https://openrouter.ai/api/v1/chat/completions",
                headers={"Authorization": f"Bearer {OPENROUTER_KEY}", "Content-Type": "application/json"},
                json={"model": model_id, "max_tokens": 8000, "temperature": 0.3,
                      "messages": [{"role": "system", "content": "You are an elite web developer. Return complete HTML with premium dark theme design."},
                                   {"role": "user", "content": prompt}]}, timeout=300)
            if r.ok:
                html = r.json()["choices"][0]["message"]["content"]
                if html and len(html) > 500:
                    add_log(f"โœ… {name}")
                    if "```html" in html:
                        html = html.split("```html")[-1].split("```")[0]
                    return html
        except: pass
    return ""
    

def get_design_rules():
    return """DESIGN RULES:
- Dark background #0A0A0F โ€” NEVER white
- Orange #FF6B00 accent on headings, buttons, icons
- Bebas Neue (headings) + DM Sans (body) + Space Mono (labels) from Google Fonts CDN
- Cards: #111118, 14px radius, #2A2A38 border, orange top accent line
- Hero: gradient background with radial glow
- Stats: Bebas Neue 48px orange numbers
- Buttons: Space Mono bold, orange primary
- Font Awesome 6 CDN icons
- Real Hindi+English content, Indian names, NO Lorem Ipsum
- Mobile responsive"""

# ========== ALL WEBSITE BUILDERS ==========

@app.route("/api/build-premium", methods=["POST"])
def build_premium():
    data = request.json
    niche = data.get("niche", "AI Tools")
    site_type = data.get("type", "website")
    add_log(f"โœจ Premium: {niche}")
    
    extras = {
        "movie": """MOVIE WEBSITE - CRITICAL INSTRUCTIONS:

YOU MUST INCLUDE 50 MOVIES MINIMUM in a responsive grid.

FOR EVERY SINGLE MOVIE CARD, you MUST include this EXACT YouTube embed code:
<iframe width='100%' height='200' src='https://www.youtube.com/embed/VIDEO_ID' frameborder='0' allowfullscreen style='border-radius:10px;'></iframe>

USE THESE EXACT 50 MOVIES with YouTube IDs:
Deadpool 3(ztLkQZx1HMsโญ8.5), Dune 2(Way9Dexny3wโญ9.0), Godzilla x Kong(lV1OOlGw3FMโญ7.8), Kung Fu Panda 4(_inKs4eeHiIโญ7.2), Furiosa(XJMuhwV6cA4โญ8.0), Inside Out 2(LAfT8Mn3pcโญ8.3), Avatar 3, Avengers Secret Wars, Spider-Man 4, Superman Legacy, Fantastic Four, Blade, Thunderbolts, Captain America 4, Joker 2, Venom 3, Bad Boys 4, Despicable Me 4, Sonic 3, Mufasa, Kraven, Madame Web, Aquaman 2, Transformers 8, Fast Furious 11, Mission Impossible 8, John Wick 5, Extraction 3, The Equalizer 4, Alien Romulus, A Quiet Place 3, Scream 7, Saw 11, The Conjuring 4, Ghostbusters 5, Beetlejuice 2, Twisters, Gladiator 2, Wicked, Wonka 2, Minecraft Movie, Borderlands, Mortal Kombat 2, Street Fighter, Resident Evil, Silent Hill, Five Nights at Freddys 2, The Crow, Snow White, Moana 2, Mufasa The Lion King.

EVERY CARD MUST HAVE:
1. The YouTube embed iframe above
2. Movie name in Hindi + English
3. โญ IMDB rating
4. Genre tags
5. "Watch Full Movie" button linking to: https://www.youtube.com/results?search_query=MOVIE_NAME+hindi+dubbed+full+movie
6. Hindi description (2 lines)

Include: Working search bar, Category filters (All, Action, Sci-Fi, Horror, Comedy, Animation).

CRITICAL: The YouTube iframe MUST be present in EVERY movie card. This is non-negotiable.""",

        "game": """GAMING WEBSITE with 20 games:
Games: Free Fire Max, BGMI, GTA 6, Minecraft, PUBG Mobile, Call of Duty Mobile, Clash of Clans, Subway Surfers, Temple Run, Candy Crush, Asphalt 9, FIFA Mobile, GTA 5, Valorant, Fortnite, Among Us, Roblox, Apex Legends, Clash Royale, eFootball.
Each card: Game name+emoji, category, download size, โญ rating, Hindi description, "Download Guide" button, "Tips & Tricks" button.
Include: Category filters, "How to Download" steps, Latest News section.""",

        "tool": """TOOLS WEBSITE with REAL working JavaScript tools:
Build 3-4 WORKING tools: Calculator, Converter, Generator, or Resizer.
Each tool must have REAL JavaScript that actually works when user interacts.
Include: Tool name, description, working input/output.""",

        "smm": """SMM PANEL with real services:
Services: Instagram Followers(โ‚น199), Instagram Likes(โ‚น49), YouTube Views(โ‚น149), YouTube Subscribers(โ‚น299), Facebook Likes(โ‚น79), Twitter Followers(โ‚น149), Telegram Members(โ‚น99), WhatsApp Channel(โ‚น129).
Each: Platform icon, service name, price, min-max, "Order Now" button.
Include: How It Works, Payment methods, Live order counter, FAQ.""",

        "news": """NEWS WEBSITE auto-updating:
Include: Latest news section, category filters (India, World, Tech, Sports, Entertainment), trending topics, search bar.
Design news cards with title, image placeholder, category tag, time, summary.""",

        "education": """EDUCATION WEBSITE for Indian students:
Subjects: UPSC, SSC, Banking, Railway, NEET, JEE.
Each: Study material, PDF links, YouTube video embeds, quiz section.
Include: Subject filters, search, "Download Notes" buttons.""",

        "finance": """FINANCE TOOLS WEBSITE:
Tools: Income Tax Calculator(working JS), EMI Calculator(working JS), SIP Calculator, GST Calculator, Salary Calculator.
Each: Input fields, calculate button, result display with charts.
Include: Financial tips blog section.""",

        "sports": """SPORTS WEBSITE for Indian audience:
Cricket: Live score section, IPL 2025, Team India schedule.
Football: FIFA World Cup, ISL.
Include: Score cards, match schedule, news updates.""",

        "music": """MUSIC WEBSITE:
Bollywood songs, Devotional, Punjabi, Latest hits.
Each: Song name, artist, YouTube embed player, download link.
Include: Genre filters, search, Top 20 chart.""",

        "apps": """APPS/MODS WEBSITE:
Apps: GB WhatsApp, Instagram Pro, YouTube Vanced, Spotify Mod, Netflix Mod, CapCut Pro, PicsArt Gold, Kinemaster Mod, Free Fire Mod, BGMI Mod.
Each: App icon, name, version, size, features list, "Download" button.
Include: Category filters, "How to Install" guide, FAQ."""
    }
    
    prompt = f"""Build a PREMIUM {site_type.upper()} WEBSITE for: {niche}.
{get_design_rules()}
{extras.get(site_type, "Premium website with all sections.")}
SECTIONS: Nav, Hero, Stats(4), Items Grid, Testimonials(3 Indian), FAQ(8), Contact, Footer.
Return COMPLETE HTML: <!DOCTYPE html>, CSS in <style>, JS in <script>."""

    html = call_best_ai(prompt)
    if html:
        stats["sites"] += 1
        return jsonify({"success": True, "website": html, "size": len(html), "type": site_type})
    return jsonify({"success": False, "error": "All AIs failed"})

@app.route("/api/build-pro-site", methods=["POST"])
def build_pro_site():
    data = request.json
    niche = data.get("niche", "AI Tools")
    add_log(f"PRO: {niche}")
    prompt = f"Build a premium website for {niche}. {get_design_rules()} All sections. Real content. Return HTML."
    html = call_best_ai(prompt)
    if html:
        stats["sites"] += 1
        return jsonify({"success": True, "website": html, "size": len(html)})
    return jsonify({"success": False, "error": "Failed"})

@app.route("/api/build-website", methods=["POST"])
def build_website():
    data = request.json
    niche = data.get("niche", "AI Tools")
    try:
        r = requests.post(f"{VERCEL}/api/website-empire", json={"action": "build-site", "niche": niche}, timeout=180)
        d = r.json()
        if d.get("success"):
            stats["sites"] += 1
            return jsonify({"success": True, "website": d.get("website", ""), "size": len(d.get("website", ""))})
        return jsonify({"success": False, "error": d.get("error")})
    except Exception as e:
        return jsonify({"success": False, "error": str(e)})

@app.route("/api/deploy", methods=["POST"])
def deploy():
    data = request.json
    html = data.get("html", "")
    niche = data.get("niche", "website")
    if not html: return jsonify({"success": False})
    stats["deployed"] += 1
    return jsonify({"success": True, "url": f"https://{niche.replace(' ','-').lower()[:30]}.vercel.app", "steps": ["Download HTML", "Go to vercel.com/new", "Drag & drop", "LIVE!"]})

@app.route("/api/stats")
def get_stats(): return jsonify(stats)

@app.route("/api/logs")
def get_logs(): return jsonify({"logs": logs[-30:]})

@app.route("/api/start-auto", methods=["POST"])
def start_auto():
    global running
    if not running:
        running = True
        threading.Thread(target=auto_loop, daemon=True).start()
        return jsonify({"status": "started"})
    return jsonify({"status": "already_running"})

def auto_loop():
    global running
    niches = [
        ("Hollywood Movies Hindi", "movie"), ("Free Fire Guide", "game"),
        ("Tax Calculator India", "tool"), ("SMM Panel India", "smm"),
        ("Today News Hindi", "news"), ("UPSC Study Material", "education"),
        ("EMI Calculator", "finance"), ("IPL 2025 Live Score", "sports"),
        ("Bollywood Songs", "music"), ("GB WhatsApp Download", "apps"),
    ]
    while running:
        for niche, stype in niches:
            if not running: break
            try:
                r = requests.post("http://127.0.0.1:7860/api/build-premium", json={"niche": niche, "type": stype}, timeout=300)
                if r.json().get("success"): stats["sites"] += 1
            except: pass
            time.sleep(30)

@app.route("/")
def home():
    return """
    <!DOCTYPE html>
    <html>
    <head>
        <title>AI Empire Brain 2070</title>
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <style>
            * { margin:0; padding:0; box-sizing:border-box; }
            body { background:#0A0A0F; color:#E8E8F0; font-family:Arial; min-height:100vh; }
            .header { background:linear-gradient(135deg,#1a0033,#0a0a2e); padding:20px; text-align:center; border-bottom:2px solid #2A2A38; }
            h1 { font-size:clamp(22px,5vw,36px); background:linear-gradient(to right,#FF6B00,#FF00FF,#00AAFF); -webkit-background-clip:text; -webkit-text-fill-color:transparent; }
            .stats { display:grid; grid-template-columns:repeat(4,1fr); gap:8px; padding:12px; }
            .stat { background:#111118; padding:10px; border-radius:8px; text-align:center; border:1px solid #2A2A38; }
            .stat p { font-size:20px; font-weight:bold; color:#FF6B00; }
            .stat h3 { color:#5A5A70; font-size:8px; text-transform:uppercase; }
            .container { max-width:750px; margin:0 auto; padding:12px; }
            input { width:100%; padding:12px; border-radius:8px; border:1px solid #2A2A38; background:#111118; color:white; font-size:14px; margin-bottom:6px; }
            button { width:100%; padding:12px; border-radius:8px; border:none; font-size:13px; font-weight:bold; cursor:pointer; margin-bottom:5px; }
            .btn-movie { background:linear-gradient(135deg,#FF0000,#FF6B00); color:white; }
            .btn-game { background:linear-gradient(135deg,#00AAFF,#9B6BFF); color:white; }
            .btn-tool { background:linear-gradient(135deg,#00D46A,#00AAFF); color:black; }
            .btn-smm { background:linear-gradient(135deg,#E91E63,#9C27B0); color:white; }
            .btn-news { background:linear-gradient(135deg,#FF9800,#FF5722); color:white; }
            .btn-edu { background:linear-gradient(135deg,#4CAF50,#8BC34A); color:black; }
            .btn-fin { background:linear-gradient(135deg,#2196F3,#03A9F4); color:white; }
            .btn-sport { background:linear-gradient(135deg,#F44336,#FF9800); color:white; }
            .btn-music { background:linear-gradient(135deg,#9C27B0,#E91E63); color:white; }
            .btn-apps { background:linear-gradient(135deg,#607D8B,#37474F); color:white; }
            .btn-pro { background:linear-gradient(135deg,#FFD700,#FF6B00); color:black; }
            .btn-basic { background:linear-gradient(135deg,#00D46A,#4FA3FF); color:black; }
            .btn-deploy { background:#4FA3FF; color:white; }
            .btn-red { background:#FF3B5C; color:white; }
            .result { background:#111118; padding:12px; border-radius:8px; margin-top:8px; white-space:pre-wrap; font-size:12px; max-height:400px; overflow-y:auto; border:1px solid #2A2A38; }
            iframe { width:100%; height:400px; border:1px solid #333; border-radius:8px; margin-top:8px; background:white; display:none; }
        </style>
    </head>
    <body>
        <div class="header"><h1>๐Ÿง  AI EMPIRE BRAIN 2070</h1><p style="color:#5A5A70;font-size:11px;">10 Website Types | Claude + DeepSeek + Gemini | OpenRouter</p></div>
        <div class="stats">
            <div class="stat"><h3>๐ŸŒ Built</h3><p id="site-count">0</p></div>
            <div class="stat"><h3>๐Ÿš€ Deploy</h3><p id="deploy-count">0</p></div>
            <div class="stat"><h3>๐Ÿค– AIs</h3><p>3</p></div>
            <div class="stat"><h3>๐Ÿ“š Types</h3><p>10</p></div>
        </div>
        <div class="container">
            <input id="niche" placeholder="Enter niche...">
            <button class="btn-movie" onclick="build('movie')">๐ŸŽฌ MOVIES (50+ Trailers)</button>
            <button class="btn-game" onclick="build('game')">๐ŸŽฎ GAMING (20 Games)</button>
            <button class="btn-tool" onclick="build('tool')">๐Ÿ› ๏ธ TOOLS (Working JS)</button>
            <button class="btn-smm" onclick="build('smm')">๐Ÿ‘ฅ SMM PANEL</button>
            <button class="btn-news" onclick="build('news')">๐Ÿ“ฐ NEWS SITE</button>
            <button class="btn-edu" onclick="build('education')">๐Ÿ“š EDUCATION</button>
            <button class="btn-fin" onclick="build('finance')">๐Ÿ’ฐ FINANCE TOOLS</button>
            <button class="btn-sport" onclick="build('sports')">๐Ÿ SPORTS</button>
            <button class="btn-music" onclick="build('music')">๐ŸŽต MUSIC</button>
            <button class="btn-apps" onclick="build('apps')">๐Ÿ“ฑ APPS/MODS</button>
            <button class="btn-pro" onclick="buildPro()">๐Ÿข PRO SITE</button>
            <button class="btn-basic" onclick="buildBasic()">๐ŸŒ BASIC</button>
            <button class="btn-deploy" onclick="deploySite()">๐Ÿš€ DEPLOY TO LIVE URL</button>
            <button class="btn-red" onclick="startAuto()">โšก AUTO-PILOT 24/7</button>
            <div id="result" class="result">โœจ 10 website types! Choose one and build with Claude + DeepSeek + Gemini!</div>
        </div>
        <script>
            const API = window.location.origin;
            let currentWebsite = '';
            
            async function build(type) {
                const n = document.getElementById('niche').value || getDefaultNiche(type);
                document.getElementById('result').innerHTML = 'โณ Building premium ' + type + ' site...';
                const r = await fetch(API+'/api/build-premium', {method:'POST', headers:{'Content-Type':'application/json'}, body:JSON.stringify({niche:n, type:type})});
                showResult(await r.json());
            }
            
            function getDefaultNiche(type) {
                const defaults = {movie:'Hollywood Movies Hindi Dubbed',game:'Mobile Games Download',tool:'Free Online Tools',smm:'SMM Panel India',news:'Today News Hindi',education:'UPSC Study Material',finance:'Income Tax Calculator',sports:'IPL Live Score 2025',music:'Bollywood Songs 2025',apps:'GB WhatsApp Download'};
                return defaults[type] || 'AI Tools';
            }
            
            async function buildPro() {
                const n = document.getElementById('niche').value || 'AI Tools';
                document.getElementById('result').innerHTML = '๐Ÿข Building PRO...';
                const r = await fetch(API+'/api/build-pro-site', {method:'POST', headers:{'Content-Type':'application/json'}, body:JSON.stringify({niche:n})});
                showResult(await r.json());
            }
            
            async function buildBasic() {
                const n = document.getElementById('niche').value || 'AI Tools';
                document.getElementById('result').innerHTML = '๐ŸŒ Building...';
                const r = await fetch(API+'/api/build-website', {method:'POST', headers:{'Content-Type':'application/json'}, body:JSON.stringify({niche:n})});
                showResult(await r.json());
            }
            
            function showResult(d) {
                if(d.success) {
                    currentWebsite = d.website;
                    document.getElementById('result').innerHTML = 'โœ… BUILT! Size: '+d.size+' chars | Type: '+(d.type||'website')+'<br><br>'+
                        '<button onclick="preview()" style="background:#4FA3FF;color:white;padding:10px;border-radius:8px;border:none;cursor:pointer;">๐Ÿ‘๏ธ Preview</button> '+
                        '<button onclick="downloadSite()" style="background:#FFD700;color:black;padding:10px;border-radius:8px;border:none;cursor:pointer;">๐Ÿ“ฅ Download</button> '+
                        '<button onclick="showCode()" style="background:#00D46A;color:black;padding:10px;border-radius:8px;border:none;cursor:pointer;">๐Ÿ“‹ Show Code</button>'+
                        '<br><iframe id="pf"></iframe>'+
                        '<textarea id="codeArea" style="width:100%;height:300px;background:#000;color:#0f0;font-size:11px;margin-top:10px;display:none;" onclick="this.select()"></textarea>';
                } else {
                    document.getElementById('result').innerHTML = 'โŒ '+ (d.error || 'Failed');
                }
                updateStats();
            }
            
            function preview() { const f=document.getElementById('pf'); f.style.display=f.style.display==='none'?'block':'none'; if(f.style.display==='block') f.srcdoc=currentWebsite; }
            
            function downloadSite() {
                const blob = new Blob([currentWebsite], {type:'text/html'});
                const url = URL.createObjectURL(blob);
                const a = document.createElement('a');
                a.href = url; a.download = 'website.html';
                document.body.appendChild(a); a.click();
                document.body.removeChild(a); URL.revokeObjectURL(url);
            }
            
            function showCode() {
                const ta = document.getElementById('codeArea');
                if (ta.style.display === 'none') {
                    ta.style.display = 'block'; ta.value = currentWebsite; ta.select();
                } else { ta.style.display = 'none'; }
            }
            
            async function deploySite() {
                if(!currentWebsite) { alert('Build first!'); return; }
                const n = document.getElementById('niche').value || 'website';
                const r = await fetch(API+'/api/deploy', {method:'POST', headers:{'Content-Type':'application/json'}, body:JSON.stringify({html:currentWebsite, niche:n})});
                const d = await r.json();
                document.getElementById('result').innerHTML = d.success ? 'โœ… Ready!<br><b>'+d.url+'</b><br>'+d.steps.join('<br>') : 'โŒ Failed';
            }
            
            async function startAuto() { 
                await fetch(API+'/api/start-auto',{method:'POST'}); 
                document.getElementById('status-text').innerHTML='RUNNING'; 
                document.getElementById('status-text').style.color='#00D46A';
            }
            
            async function updateStats() { 
                const r=await fetch(API+'/api/stats'); const d=await r.json();
                document.getElementById('site-count').innerHTML=d.sites||0;
                document.getElementById('deploy-count').innerHTML=d.deployed||0;
            }
            updateStats();
        </script>
    </body>
    </html>
    """

if __name__ == "__main__":
    app.run(host="0.0.0.0", port=7860)