Buckets:
| import os | |
| import json | |
| def init_project(name: str, framework: str = "Tailwind CDN") -> str: | |
| """ | |
| Initializes a website project structure. | |
| """ | |
| base_path = os.path.join(os.getcwd(), "web_projects", name) | |
| os.makedirs(base_path, exist_ok=True) | |
| index_content = "" | |
| if framework == "Tailwind CDN": | |
| index_content = f"""<!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <script src="https://cdn.tailwindcss.com"></script> | |
| <title>{name}</title> | |
| </head> | |
| <body class="bg-gray-50 text-gray-900"> | |
| <!-- Navbar --> | |
| <div id="navbar"></div> | |
| <!-- Hero Section --> | |
| <div id="hero"></div> | |
| <!-- Content --> | |
| <main id="content" class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-12"> | |
| <h1 class="text-4xl font-bold text-center">Welcome to {name}</h1> | |
| </main> | |
| <!-- Footer --> | |
| <div id="footer"></div> | |
| </body> | |
| </html>""" | |
| else: | |
| index_content = f"<!DOCTYPE html><html><head><title>{name}</title></head><body><h1>{name}</h1></body></html>" | |
| with open(os.path.join(base_path, "index.html"), "w") as f: | |
| f.write(index_content) | |
| # Create asset folders | |
| for d in ["css", "js", "img"]: | |
| os.makedirs(os.path.join(base_path, d), exist_ok=True) | |
| return f"Project '{name}' ({framework}) initialized at {base_path}" | |
Xet Storage Details
- Size:
- 1.41 kB
- Xet hash:
- ca38be1b95c5a7099a7f3dbf76a9d71ce22fc227877129cbbc703e60900b0bf5
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.