Spaces:
Configuration error
Configuration error
File size: 583 Bytes
317ca5c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
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 |