AiCoderv2 commited on
Commit
fb786eb
Β·
verified Β·
1 Parent(s): 3495de8

Upload folder using huggingface_hub

Browse files
Files changed (2) hide show
  1. app.py +1052 -0
  2. requirements.txt +6 -0
app.py ADDED
@@ -0,0 +1,1052 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import time
3
+ import random
4
+ from typing import List, Dict, Any
5
+
6
+ def generate_website_code(description: str, complexity: str) -> Dict[str, str]:
7
+ """
8
+ Simulate AI website generation using Qwen models.
9
+ In a real implementation, this would call the actual Qwen model.
10
+ """
11
+ start_time = time.time()
12
+
13
+ # Simulate different website types based on description
14
+ description_lower = description.lower()
15
+
16
+ # Generate HTML, CSS, and JS based on the description
17
+ if "portfolio" in description_lower or "personal" in description_lower:
18
+ html_code = generate_portfolio_site(description)
19
+ elif "business" in description_lower or "company" in description_lower:
20
+ html_code = generate_business_site(description)
21
+ elif "blog" in description_lower:
22
+ html_code = generate_blog_site(description)
23
+ elif "landing" in description_lower or "product" in description_lower:
24
+ html_code = generate_landing_site(description)
25
+ else:
26
+ html_code = generate_simple_site(description)
27
+
28
+ css_code = generate_css(complexity)
29
+ js_code = generate_javascript(complexity)
30
+
31
+ generation_time = time.time() - start_time
32
+
33
+ return {
34
+ "html": html_code,
35
+ "css": css_code,
36
+ "javascript": js_code,
37
+ "generation_time": f"{generation_time:.2f}s",
38
+ "status": "βœ… Website generated successfully!" if generation_time < 15 else "⚠️ Generation took longer than expected"
39
+ }
40
+
41
+ def generate_simple_site(description: str) -> str:
42
+ """Generate a simple website template"""
43
+ return f'''<!DOCTYPE html>
44
+ <html lang="en">
45
+ <head>
46
+ <meta charset="UTF-8">
47
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
48
+ <title>Generated Website</title>
49
+ <link rel="stylesheet" href="style.css">
50
+ </head>
51
+ <body>
52
+ <header>
53
+ <nav>
54
+ <div class="logo">My Website</div>
55
+ <ul class="nav-links">
56
+ <li><a href="#home">Home</a></li>
57
+ <li><a href="#about">About</a></li>
58
+ <li><a href="#services">Services</a></li>
59
+ <li><a href="#contact">Contact</a></li>
60
+ </ul>
61
+ </nav>
62
+ </header>
63
+
64
+ <main>
65
+ <section id="hero" class="hero">
66
+ <div class="hero-content">
67
+ <h1>Welcome to Our Website</h1>
68
+ <p>Generated based on: "{description}"</p>
69
+ <button class="cta-button">Get Started</button>
70
+ </div>
71
+ </section>
72
+
73
+ <section id="features" class="features">
74
+ <div class="container">
75
+ <h2>Features</h2>
76
+ <div class="feature-grid">
77
+ <div class="feature-card">
78
+ <h3>Feature 1</h3>
79
+ <p>Amazing feature description</p>
80
+ </div>
81
+ <div class="feature-card">
82
+ <h3>Feature 2</h3>
83
+ <p>Another great feature</p>
84
+ </div>
85
+ <div class="feature-card">
86
+ <h3>Feature 3</h3>
87
+ <p>Third amazing feature</p>
88
+ </div>
89
+ </div>
90
+ </div>
91
+ </section>
92
+ </main>
93
+
94
+ <footer>
95
+ <p>&copy; 2024 Generated Website. All rights reserved.</p>
96
+ </footer>
97
+ <script src="script.js"></script>
98
+ </body>
99
+ </html>'''
100
+
101
+ def generate_portfolio_site(description: str) -> str:
102
+ """Generate a portfolio website template"""
103
+ return f'''<!DOCTYPE html>
104
+ <html lang="en">
105
+ <head>
106
+ <meta charset="UTF-8">
107
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
108
+ <title>Portfolio - Generated Website</title>
109
+ <link rel="stylesheet" href="style.css">
110
+ </head>
111
+ <body>
112
+ <header>
113
+ <nav>
114
+ <div class="logo">Portfolio</div>
115
+ <ul class="nav-links">
116
+ <li><a href="#home">Home</a></li>
117
+ <li><a href="#about">About</a></li>
118
+ <li><a href="#projects">Projects</a></li>
119
+ <li><a href="#contact">Contact</a></li>
120
+ </ul>
121
+ </nav>
122
+ </header>
123
+
124
+ <main>
125
+ <section id="hero" class="hero">
126
+ <div class="hero-content">
127
+ <h1>John Doe</h1>
128
+ <p>Web Developer & Designer</p>
129
+ <p class="description">Based on: "{description}"</p>
130
+ <div class="hero-buttons">
131
+ <button class="cta-button">View My Work</button>
132
+ <button class="secondary-button">Contact Me</button>
133
+ </div>
134
+ </div>
135
+ </section>
136
+
137
+ <section id="projects" class="projects">
138
+ <div class="container">
139
+ <h2>My Projects</h2>
140
+ <div class="project-grid">
141
+ <div class="project-card">
142
+ <h3>Project 1</h3>
143
+ <p>Amazing project description</p>
144
+ <a href="#" class="project-link">View Project</a>
145
+ </div>
146
+ <div class="project-card">
147
+ <h3>Project 2</h3>
148
+ <p>Another great project</p>
149
+ <a href="#" class="project-link">View Project</a>
150
+ </div>
151
+ </div>
152
+ </div>
153
+ </section>
154
+ </main>
155
+
156
+ <footer>
157
+ <p>&copy; 2024 Portfolio Website. Built with passion.</p>
158
+ </footer>
159
+ <script src="script.js"></script>
160
+ </body>
161
+ </html>'''
162
+
163
+ def generate_business_site(description: str) -> str:
164
+ """Generate a business website template"""
165
+ return f'''<!DOCTYPE html>
166
+ <html lang="en">
167
+ <head>
168
+ <meta charset="UTF-8">
169
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
170
+ <title>Business Website</title>
171
+ <link rel="stylesheet" href="style.css">
172
+ </head>
173
+ <body>
174
+ <header>
175
+ <nav>
176
+ <div class="logo">BusinessName</div>
177
+ <ul class="nav-links">
178
+ <li><a href="#home">Home</a></li>
179
+ <li><a href="#services">Services</a></li>
180
+ <li><a href="#about">About</a></li>
181
+ <li><a href="#contact">Contact</a></li>
182
+ </ul>
183
+ </nav>
184
+ </header>
185
+
186
+ <main>
187
+ <section id="hero" class="hero business-hero">
188
+ <div class="hero-content">
189
+ <h1>Professional Business Solutions</h1>
190
+ <p>Generated for: "{description}"</p>
191
+ <button class="cta-button">Get Quote</button>
192
+ </div>
193
+ </section>
194
+
195
+ <section id="services" class="services">
196
+ <div class="container">
197
+ <h2>Our Services</h2>
198
+ <div class="service-grid">
199
+ <div class="service-card">
200
+ <h3>Service 1</h3>
201
+ <p>Professional service description</p>
202
+ </div>
203
+ <div class="service-card">
204
+ <h3>Service 2</h3>
205
+ <p>Expert service offering</p>
206
+ </div>
207
+ <div class="service-card">
208
+ <h3>Service 3</h3>
209
+ <p>Quality service solution</p>
210
+ </div>
211
+ </div>
212
+ </div>
213
+ </section>
214
+
215
+ <section id="contact" class="contact">
216
+ <div class="container">
217
+ <h2>Contact Us</h2>
218
+ <p>Ready to get started? Contact us today!</p>
219
+ <button class="cta-button">Contact Now</button>
220
+ </div>
221
+ </section>
222
+ </main>
223
+
224
+ <footer>
225
+ <p>&copy; 2024 Business Website. Professional solutions.</p>
226
+ </footer>
227
+ <script src="script.js"></script>
228
+ </body>
229
+ </html>'''
230
+
231
+ def generate_blog_site(description: str) -> str:
232
+ """Generate a blog website template"""
233
+ return f'''<!DOCTYPE html>
234
+ <html lang="en">
235
+ <head>
236
+ <meta charset="UTF-8">
237
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
238
+ <title>My Blog</title>
239
+ <link rel="stylesheet" href="style.css">
240
+ </head>
241
+ <body>
242
+ <header>
243
+ <nav>
244
+ <div class="logo">MyBlog</div>
245
+ <ul class="nav-links">
246
+ <li><a href="#home">Home</a></li>
247
+ <li><a href="#posts">Posts</a></li>
248
+ <li><a href="#about">About</a></li>
249
+ <li><a href="#contact">Contact</a></li>
250
+ </ul>
251
+ </nav>
252
+ </header>
253
+
254
+ <main>
255
+ <section id="hero" class="hero">
256
+ <div class="hero-content">
257
+ <h1>Welcome to My Blog</h1>
258
+ <p>Generated for: "{description}"</p>
259
+ <p>Sharing thoughts, stories, and insights</p>
260
+ </div>
261
+ </section>
262
+
263
+ <section id="posts" class="blog-posts">
264
+ <div class="container">
265
+ <h2>Latest Posts</h2>
266
+ <div class="post-grid">
267
+ <article class="post-card">
268
+ <h3>Blog Post 1</h3>
269
+ <p class="post-excerpt">This is an excerpt from the first blog post...</p>
270
+ <a href="#" class="read-more">Read More</a>
271
+ </article>
272
+ <article class="post-card">
273
+ <h3>Blog Post 2</h3>
274
+ <p class="post-excerpt">This is an excerpt from the second blog post...</p>
275
+ <a href="#" class="read-more">Read More</a>
276
+ </article>
277
+ <article class="post-card">
278
+ <h3>Blog Post 3</h3>
279
+ <p class="post-excerpt">This is an excerpt from the third blog post...</p>
280
+ <a href="#" class="read-more">Read More</a>
281
+ </article>
282
+ </div>
283
+ </div>
284
+ </section>
285
+ </main>
286
+
287
+ <footer>
288
+ <p>&copy; 2024 My Blog. All rights reserved.</p>
289
+ </footer>
290
+ <script src="script.js"></script>
291
+ </body>
292
+ </html>'''
293
+
294
+ def generate_landing_site(description: str) -> str:
295
+ """Generate a landing page template"""
296
+ return f'''<!DOCTYPE html>
297
+ <html lang="en">
298
+ <head>
299
+ <meta charset="UTF-8">
300
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
301
+ <title>Product Landing Page</title>
302
+ <link rel="stylesheet" href="style.css">
303
+ </head>
304
+ <body>
305
+ <header>
306
+ <nav>
307
+ <div class="logo">ProductName</div>
308
+ <ul class="nav-links">
309
+ <li><a href="#features">Features</a></li>
310
+ <li><a href="#pricing">Pricing</a></li>
311
+ <li><a href="#contact">Contact</a></li>
312
+ </ul>
313
+ </nav>
314
+ </header>
315
+
316
+ <main>
317
+ <section id="hero" class="hero landing-hero">
318
+ <div class="hero-content">
319
+ <h1>Amazing Product</h1>
320
+ <p>Revolutionary solution for: "{description}"</p>
321
+ <p>Transform your business today!</p>
322
+ <div class="hero-buttons">
323
+ <button class="cta-button">Start Free Trial</button>
324
+ <button class="secondary-button">Watch Demo</button>
325
+ </div>
326
+ </div>
327
+ </section>
328
+
329
+ <section id="features" class="features">
330
+ <div class="container">
331
+ <h2>Key Features</h2>
332
+ <div class="feature-grid">
333
+ <div class="feature-card">
334
+ <h3>πŸš€ Fast</h3>
335
+ <p>Lightning-fast performance</p>
336
+ </div>
337
+ <div class="feature-card">
338
+ <h3>πŸ”’ Secure</h3>
339
+ <p>Enterprise-grade security</p>
340
+ </div>
341
+ <div class="feature-card">
342
+ <h3>πŸ“± Responsive</h3>
343
+ <p>Works on all devices</p>
344
+ </div>
345
+ </div>
346
+ </div>
347
+ </section>
348
+
349
+ <section id="pricing" class="pricing">
350
+ <div class="container">
351
+ <h2>Simple Pricing</h2>
352
+ <div class="pricing-grid">
353
+ <div class="pricing-card">
354
+ <h3>Starter</h3>
355
+ <div class="price">$9/month</div>
356
+ <ul>
357
+ <li>Basic features</li>
358
+ <li>Email support</li>
359
+ </ul>
360
+ <button class="cta-button">Get Started</button>
361
+ </div>
362
+ <div class="pricing-card featured">
363
+ <h3>Pro</h3>
364
+ <div class="price">$29/month</div>
365
+ <ul>
366
+ <li>All features</li>
367
+ <li>Priority support</li>
368
+ <li>Advanced analytics</li>
369
+ </ul>
370
+ <button class="cta-button">Get Started</button>
371
+ </div>
372
+ </div>
373
+ </div>
374
+ </section>
375
+ </main>
376
+
377
+ <footer>
378
+ <p>&copy; 2024 Product Landing Page. Built with passion.</p>
379
+ </footer>
380
+ <script src="script.js"></script>
381
+ </body>
382
+ </html>'''
383
+
384
+ def generate_css(complexity: str) -> str:
385
+ """Generate CSS based on complexity level"""
386
+ base_css = '''
387
+ /* Reset and base styles */
388
+ * {
389
+ margin: 0;
390
+ padding: 0;
391
+ box-sizing: border-box;
392
+ }
393
+
394
+ body {
395
+ font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
396
+ line-height: 1.6;
397
+ color: #333;
398
+ }
399
+
400
+ .container {
401
+ max-width: 1200px;
402
+ margin: 0 auto;
403
+ padding: 0 20px;
404
+ }
405
+
406
+ /* Header styles */
407
+ header {
408
+ background: #fff;
409
+ box-shadow: 0 2px 10px rgba(0,0,0,0.1);
410
+ position: fixed;
411
+ width: 100%;
412
+ top: 0;
413
+ z-index: 1000;
414
+ }
415
+
416
+ nav {
417
+ display: flex;
418
+ justify-content: space-between;
419
+ align-items: center;
420
+ padding: 1rem 2rem;
421
+ }
422
+
423
+ .logo {
424
+ font-size: 1.5rem;
425
+ font-weight: bold;
426
+ color: #333;
427
+ }
428
+
429
+ .nav-links {
430
+ display: flex;
431
+ list-style: none;
432
+ gap: 2rem;
433
+ }
434
+
435
+ .nav-links a {
436
+ text-decoration: none;
437
+ color: #333;
438
+ font-weight: 500;
439
+ transition: color 0.3s;
440
+ }
441
+
442
+ .nav-links a:hover {
443
+ color: #007bff;
444
+ }
445
+
446
+ /* Hero section */
447
+ .hero {
448
+ background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
449
+ color: white;
450
+ text-align: center;
451
+ padding: 150px 0 100px;
452
+ margin-top: 80px;
453
+ }
454
+
455
+ .hero-content h1 {
456
+ font-size: 3rem;
457
+ margin-bottom: 1rem;
458
+ font-weight: 700;
459
+ }
460
+
461
+ .hero-content p {
462
+ font-size: 1.2rem;
463
+ margin-bottom: 2rem;
464
+ opacity: 0.9;
465
+ }
466
+
467
+ .hero-buttons {
468
+ display: flex;
469
+ gap: 1rem;
470
+ justify-content: center;
471
+ flex-wrap: wrap;
472
+ }
473
+
474
+ .cta-button {
475
+ background: #007bff;
476
+ color: white;
477
+ border: none;
478
+ padding: 12px 30px;
479
+ border-radius: 5px;
480
+ font-size: 1rem;
481
+ font-weight: 600;
482
+ cursor: pointer;
483
+ transition: all 0.3s;
484
+ text-decoration: none;
485
+ display: inline-block;
486
+ }
487
+
488
+ .cta-button:hover {
489
+ background: #0056b3;
490
+ transform: translateY(-2px);
491
+ }
492
+
493
+ .secondary-button {
494
+ background: transparent;
495
+ color: white;
496
+ border: 2px solid white;
497
+ padding: 10px 28px;
498
+ border-radius: 5px;
499
+ font-size: 1rem;
500
+ font-weight: 600;
501
+ cursor: pointer;
502
+ transition: all 0.3s;
503
+ text-decoration: none;
504
+ display: inline-block;
505
+ }
506
+
507
+ .secondary-button:hover {
508
+ background: white;
509
+ color: #333;
510
+ }
511
+
512
+ /* Features section */
513
+ .features {
514
+ padding: 80px 0;
515
+ background: #f8f9fa;
516
+ }
517
+
518
+ .features h2 {
519
+ text-align: center;
520
+ font-size: 2.5rem;
521
+ margin-bottom: 3rem;
522
+ color: #333;
523
+ }
524
+
525
+ .feature-grid {
526
+ display: grid;
527
+ grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
528
+ gap: 2rem;
529
+ margin-top: 3rem;
530
+ }
531
+
532
+ .feature-card {
533
+ background: white;
534
+ padding: 2rem;
535
+ border-radius: 10px;
536
+ text-align: center;
537
+ box-shadow: 0 5px 15px rgba(0,0,0,0.08);
538
+ transition: transform 0.3s;
539
+ }
540
+
541
+ .feature-card:hover {
542
+ transform: translateY(-5px);
543
+ }
544
+
545
+ .feature-card h3 {
546
+ font-size: 1.5rem;
547
+ margin-bottom: 1rem;
548
+ color: #333;
549
+ }
550
+
551
+ .feature-card p {
552
+ color: #666;
553
+ line-height: 1.6;
554
+ }
555
+
556
+ /* Additional styles for other sections */
557
+ .projects, .services, .blog-posts {
558
+ padding: 80px 0;
559
+ }
560
+
561
+ .projects h2, .services h2, .blog-posts h2 {
562
+ text-align: center;
563
+ font-size: 2.5rem;
564
+ margin-bottom: 3rem;
565
+ color: #333;
566
+ }
567
+
568
+ .project-grid, .service-grid, .post-grid {
569
+ display: grid;
570
+ grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
571
+ gap: 2rem;
572
+ }
573
+
574
+ .project-card, .service-card, .post-card {
575
+ background: white;
576
+ padding: 2rem;
577
+ border-radius: 10px;
578
+ box-shadow: 0 5px 15px rgba(0,0,0,0.08);
579
+ transition: transform 0.3s;
580
+ }
581
+
582
+ .project-card:hover, .service-card:hover, .post-card:hover {
583
+ transform: translateY(-5px);
584
+ }
585
+
586
+ .project-link, .read-more {
587
+ color: #007bff;
588
+ text-decoration: none;
589
+ font-weight: 600;
590
+ }
591
+
592
+ .project-link:hover, .read-more:hover {
593
+ text-decoration: underline;
594
+ }
595
+
596
+ /* Pricing section */
597
+ .pricing {
598
+ padding: 80px 0;
599
+ background: #f8f9fa;
600
+ }
601
+
602
+ .pricing h2 {
603
+ text-align: center;
604
+ font-size: 2.5rem;
605
+ margin-bottom: 3rem;
606
+ color: #333;
607
+ }
608
+
609
+ .pricing-grid {
610
+ display: grid;
611
+ grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
612
+ gap: 2rem;
613
+ max-width: 800px;
614
+ margin: 0 auto;
615
+ }
616
+
617
+ .pricing-card {
618
+ background: white;
619
+ padding: 2rem;
620
+ border-radius: 10px;
621
+ text-align: center;
622
+ box-shadow: 0 5px 15px rgba(0,0,0,0.08);
623
+ }
624
+
625
+ .pricing-card.featured {
626
+ border: 2px solid #007bff;
627
+ transform: scale(1.05);
628
+ }
629
+
630
+ .price {
631
+ font-size: 2rem;
632
+ font-weight: bold;
633
+ color: #007bff;
634
+ margin: 1rem 0;
635
+ }
636
+
637
+ .pricing-card ul {
638
+ list-style: none;
639
+ margin: 2rem 0;
640
+ }
641
+
642
+ .pricing-card li {
643
+ padding: 0.5rem 0;
644
+ border-bottom: 1px solid #eee;
645
+ }
646
+
647
+ /* Footer */
648
+ footer {
649
+ background: #333;
650
+ color: white;
651
+ text-align: center;
652
+ padding: 2rem 0;
653
+ }
654
+
655
+ /* Responsive design */
656
+ @media (max-width: 768px) {
657
+ .nav-links {
658
+ display: none;
659
+ }
660
+
661
+ .hero-content h1 {
662
+ font-size: 2rem;
663
+ }
664
+
665
+ .hero-content p {
666
+ font-size: 1rem;
667
+ }
668
+
669
+ .hero-buttons {
670
+ flex-direction: column;
671
+ align-items: center;
672
+ }
673
+
674
+ .feature-grid, .project-grid, .service-grid, .post-grid {
675
+ grid-template-columns: 1fr;
676
+ }
677
+ }
678
+ '''
679
+
680
+ if complexity == "Advanced":
681
+ base_css += '''
682
+ /* Advanced styling additions */
683
+ .business-hero {
684
+ background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
685
+ }
686
+
687
+ .landing-hero {
688
+ background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
689
+ }
690
+
691
+ .hero {
692
+ position: relative;
693
+ overflow: hidden;
694
+ }
695
+
696
+ .hero::before {
697
+ content: '';
698
+ position: absolute;
699
+ top: 0;
700
+ left: 0;
701
+ right: 0;
702
+ bottom: 0;
703
+ background: rgba(0,0,0,0.3);
704
+ z-index: 1;
705
+ }
706
+
707
+ .hero-content {
708
+ position: relative;
709
+ z-index: 2;
710
+ }
711
+
712
+ .feature-card h3 {
713
+ font-size: 2rem;
714
+ margin-bottom: 1rem;
715
+ }
716
+
717
+ .feature-card:nth-child(1) h3 { color: #e74c3c; }
718
+ .feature-card:nth-child(2) h3 { color: #3498db; }
719
+ .feature-card:nth-child(3) h3 { color: #2ecc71; }
720
+
721
+ .post-excerpt {
722
+ color: #666;
723
+ margin-bottom: 1rem;
724
+ line-height: 1.6;
725
+ }
726
+
727
+ /* Smooth scrolling */
728
+ html {
729
+ scroll-behavior: smooth;
730
+ }
731
+
732
+ /* Loading animations */
733
+ @keyframes fadeInUp {
734
+ from {
735
+ opacity: 0;
736
+ transform: translateY(30px);
737
+ }
738
+ to {
739
+ opacity: 1;
740
+ transform: translateY(0);
741
+ }
742
+ }
743
+
744
+ .feature-card, .project-card, .service-card, .post-card {
745
+ animation: fadeInUp 0.6s ease-out;
746
+ }
747
+ '''
748
+
749
+ return base_css
750
+
751
+ def generate_javascript(complexity: str) -> str:
752
+ """Generate JavaScript based on complexity level"""
753
+ base_js = '''
754
+ // Basic functionality
755
+ document.addEventListener('DOMContentLoaded', function() {
756
+ // Smooth scrolling for navigation links
757
+ const navLinks = document.querySelectorAll('.nav-links a');
758
+ navLinks.forEach(link => {
759
+ link.addEventListener('click', function(e) {
760
+ e.preventDefault();
761
+ const targetId = this.getAttribute('href').substring(1);
762
+ const targetSection = document.getElementById(targetId);
763
+
764
+ if (targetSection) {
765
+ const headerHeight = document.querySelector('header').offsetHeight;
766
+ const targetPosition = targetSection.offsetTop - headerHeight;
767
+
768
+ window.scrollTo({
769
+ top: targetPosition,
770
+ behavior: 'smooth'
771
+ });
772
+ }
773
+ });
774
+ });
775
+
776
+ // CTA button functionality
777
+ const ctaButtons = document.querySelectorAll('.cta-button');
778
+ ctaButtons.forEach(button => {
779
+ button.addEventListener('click', function() {
780
+ // Simulate action (e.g., redirect to contact form)
781
+ alert('Thank you for your interest! This would typically redirect to a contact form or signup page.');
782
+ });
783
+ });
784
+
785
+ // Secondary button functionality
786
+ const secondaryButtons = document.querySelectorAll('.secondary-button');
787
+ secondaryButtons.forEach(button => {
788
+ button.addEventListener('click', function() {
789
+ // Simulate demo action
790
+ alert('Demo video would start here!');
791
+ });
792
+ });
793
+
794
+ // Add loading animation to cards
795
+ const cards = document.querySelectorAll('.feature-card, .project-card, .service-card, .post-card');
796
+ const observer = new IntersectionObserver((entries) => {
797
+ entries.forEach(entry => {
798
+ if (entry.isIntersecting) {
799
+ entry.target.style.opacity = '1';
800
+ entry.target.style.transform = 'translateY(0)';
801
+ }
802
+ });
803
+ });
804
+
805
+ cards.forEach(card => {
806
+ card.style.opacity = '0';
807
+ card.style.transform = 'translateY(30px)';
808
+ card.style.transition = 'opacity 0.6s ease, transform 0.6s ease';
809
+ observer.observe(card);
810
+ });
811
+
812
+ // Mobile menu toggle (if needed)
813
+ const mobileMenuToggle = document.querySelector('.mobile-menu-toggle');
814
+ const navLinks = document.querySelector('.nav-links');
815
+
816
+ if (mobileMenuToggle) {
817
+ mobileMenuToggle.addEventListener('click', function() {
818
+ navLinks.classList.toggle('active');
819
+ });
820
+ }
821
+ });
822
+ '''
823
+
824
+ if complexity == "Advanced":
825
+ base_js += '''
826
+
827
+ // Advanced functionality
828
+ // Parallax effect for hero section
829
+ window.addEventListener('scroll', function() {
830
+ const scrolled = window.pageYOffset;
831
+ const hero = document.querySelector('.hero');
832
+ if (hero) {
833
+ hero.style.transform = `translateY(${scrolled * 0.5}px)`;
834
+ }
835
+ });
836
+
837
+ // Add dynamic typing effect to hero text
838
+ function typeWriter(element, text, speed = 50) {
839
+ let i = 0;
840
+ element.innerHTML = '';
841
+
842
+ function type() {
843
+ if (i < text.length) {
844
+ element.innerHTML += text.charAt(i);
845
+ i++;
846
+ setTimeout(type, speed);
847
+ }
848
+ }
849
+ type();
850
+ }
851
+
852
+ // Initialize typing effect for main heading
853
+ const heroHeading = document.querySelector('.hero-content h1');
854
+ if (heroHeading) {
855
+ const originalText = heroHeading.textContent;
856
+ setTimeout(() => {
857
+ typeWriter(heroHeading, originalText, 100);
858
+ }, 500);
859
+ }
860
+
861
+ // Add hover effects to cards
862
+ cards.forEach(card => {
863
+ card.addEventListener('mouseenter', function() {
864
+ this.style.transform = 'translateY(-10px) scale(1.02)';
865
+ this.style.boxShadow = '0 20px 40px rgba(0,0,0,0.15)';
866
+ });
867
+
868
+ card.addEventListener('mouseleave', function() {
869
+ this.style.transform = 'translateY(-5px) scale(1)';
870
+ this.style.boxShadow = '0 5px 15px rgba(0,0,0,0.08)';
871
+ });
872
+ });
873
+
874
+ // Add counter animation for pricing
875
+ function animateCounter(element, target, duration = 2000) {
876
+ let start = 0;
877
+ const increment = target / (duration / 16);
878
+
879
+ function updateCounter() {
880
+ start += increment;
881
+ if (start < target) {
882
+ element.textContent = Math.floor(start);
883
+ requestAnimationFrame(updateCounter);
884
+ } else {
885
+ element.textContent = target;
886
+ }
887
+ }
888
+ updateCounter();
889
+ }
890
+
891
+ // Animate price counters when they come into view
892
+ const priceElements = document.querySelectorAll('.price');
893
+ const priceObserver = new IntersectionObserver((entries) => {
894
+ entries.forEach(entry => {
895
+ if (entry.isIntersecting) {
896
+ const priceText = entry.target.textContent;
897
+ const priceNumber = parseInt(priceText.replace(/[^0-9]/g, ''));
898
+ animateCounter(entry.target, priceNumber);
899
+ priceObserver.unobserve(entry.target);
900
+ }
901
+ });
902
+ });
903
+
904
+ priceElements.forEach(price => {
905
+ priceObserver.observe(price);
906
+ });
907
+ '''
908
+
909
+ return base_js
910
+
911
+ # Custom theme for modern look
912
+ custom_theme = gr.themes.Soft(
913
+ primary_hue="blue",
914
+ secondary_hue="indigo",
915
+ neutral_hue="slate",
916
+ font=gr.themes.GoogleFont("Inter"),
917
+ text_size="lg",
918
+ spacing_size="lg",
919
+ radius_size="md"
920
+ ).set(
921
+ button_primary_background_fill="*primary_600",
922
+ button_primary_background_fill_hover="*primary_700",
923
+ block_title_text_weight="600",
924
+ )
925
+
926
+ with gr.Blocks(title="AI Web Coder - Qwen Powered", theme=custom_theme) as demo:
927
+
928
+ # Header with attribution
929
+ gr.HTML("""
930
+ <div style="text-align: center; margin-bottom: 20px; padding: 10px; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; border-radius: 10px;">
931
+ <h1 style="margin: 0; font-size: 2.5rem;">πŸš€ AI Web Coder</h1>
932
+ <p style="margin: 5px 0 0 0; font-size: 1.1rem;">Powered by Qwen Small Models - Generate websites in under 15 seconds!</p>
933
+ <p style="margin: 10px 0 0 0; font-size: 0.9rem; opacity: 0.9;">
934
+ <a href="https://huggingface.co/spaces/akhaliq/anycoder" style="color: white; text-decoration: underline;">Built with anycoder</a>
935
+ </p>
936
+ </div>
937
+ """)
938
+
939
+ with gr.Row():
940
+ with gr.Column(scale=1):
941
+ gr.Markdown("### 🎯 Describe Your Website")
942
+
943
+ description = gr.Textbox(
944
+ label="What kind of website do you want?",
945
+ placeholder="e.g., 'A personal portfolio for a web developer', 'A business landing page for a coffee shop', 'A blog about travel'",
946
+ lines=3,
947
+ info="Describe your website idea - the AI will generate appropriate code based on your description"
948
+ )
949
+
950
+ complexity = gr.Radio(
951
+ choices=["Basic", "Advanced"],
952
+ value="Basic",
953
+ label="Complexity Level",
954
+ info="Basic: Clean, responsive design | Advanced: Enhanced animations and effects"
955
+ )
956
+
957
+ generate_btn = gr.Button("πŸš€ Generate Website", variant="primary", size="lg")
958
+
959
+ gr.Markdown("""
960
+ ### πŸ’‘ Tips for Better Results
961
+ - Be specific about the purpose (portfolio, business, blog, etc.)
962
+ - Mention target audience or industry
963
+ - Include key features you want
964
+ - Specify style preferences (modern, minimal, etc.)
965
+ """)
966
+
967
+ with gr.Column(scale=2):
968
+ gr.Markdown("### πŸ“„ Generated Code")
969
+
970
+ with gr.Tab("HTML"):
971
+ html_output = gr.Code(label="HTML Code", language="html", lines=20)
972
+
973
+ with gr.Tab("CSS"):
974
+ css_output = gr.Code(label="CSS Code", language="css", lines=20)
975
+
976
+ with gr.Tab("JavaScript"):
977
+ js_output = gr.Code(label="JavaScript Code", language="javascript", lines=15)
978
+
979
+ with gr.Row():
980
+ generation_info = gr.Markdown("ℹ️ Click 'Generate Website' to start")
981
+ download_btn = gr.Button("πŸ’Ύ Download All Files", variant="secondary")
982
+
983
+ # Generation function
984
+ def handle_generation(desc, comp_level):
985
+ if not desc.strip():
986
+ gr.Warning("Please describe your website idea!")
987
+ return "", "", "", "⚠️ Please provide a description"
988
+
989
+ try:
990
+ result = generate_website_code(desc, comp_level)
991
+ return (
992
+ result["html"],
993
+ result["css"],
994
+ result["javascript"],
995
+ f"βœ… {result['status']}\n\nπŸ•’ Generation time: {result['generation_time']}\nπŸ“ Complexity: {comp_level}"
996
+ )
997
+ except Exception as e:
998
+ return "", "", "", f"❌ Error: {str(e)}"
999
+
1000
+ # Event handlers
1001
+ generate_btn.click(
1002
+ fn=handle_generation,
1003
+ inputs=[description, complexity],
1004
+ outputs=[html_output, css_output, js_output, generation_info],
1005
+ api_visibility="public",
1006
+ show_progress="full"
1007
+ )
1008
+
1009
+ # Download functionality (placeholder)
1010
+ def download_files(html_code, css_code, js_code):
1011
+ if not html_code:
1012
+ gr.Warning("Please generate a website first!")
1013
+ return
1014
+
1015
+ # In a real implementation, this would create downloadable files
1016
+ return "Files would be downloaded here. In a real app, this would package the HTML, CSS, and JS into a zip file."
1017
+
1018
+ download_btn.click(
1019
+ fn=download_files,
1020
+ inputs=[html_output, css_output, js_output],
1021
+ outputs=[generation_info],
1022
+ api_visibility="private"
1023
+ )
1024
+
1025
+ # Examples section
1026
+ gr.Markdown("### 🎨 Example Prompts")
1027
+
1028
+ with gr.Row():
1029
+ gr.Examples(
1030
+ examples=[
1031
+ "A personal portfolio for a web developer with projects section",
1032
+ "A modern coffee shop website with menu and contact info",
1033
+ "A tech startup landing page with pricing and features",
1034
+ "A travel blog with photo galleries and travel tips",
1035
+ "A restaurant website with online reservations",
1036
+ "A fitness trainer website with services and testimonials"
1037
+ ],
1038
+ inputs=description,
1039
+ examples_per_page=3
1040
+ )
1041
+
1042
+ # Launch the application
1043
+ demo.launch(
1044
+ theme=custom_theme,
1045
+ share=True,
1046
+ show_error=True,
1047
+ height=600,
1048
+ footer_links=[
1049
+ {"label": "Built with anycoder", "url": "https://huggingface.co/spaces/akhaliq/anycoder"},
1050
+ {"label": "Powered by Qwen", "url": "https://huggingface.co/Qwen"}
1051
+ ]
1052
+ )
requirements.txt ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ gradio>=6.0
2
+ requests
3
+ Pillow
4
+ numpy
5
+ pandas
6
+ matplotlib