import os import zipfile from datetime import datetime def create_zip(code_content): # Create a temporary directory if it doesn't exist os.makedirs("temp", exist_ok=True) # Save the HTML file timestamp = datetime.now().strftime("%Y%m%d_%H%M%S") html_path = f"temp/website_{timestamp}.html" with open(html_path, "w") as f: f.write(code_content) # Create a ZIP file zip_path = f"temp/website_{timestamp}.zip" with zipfile.ZipFile(zip_path, 'w') as zipf: zipf.write(html_path, arcname="index.html") return zip_path