Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added zip.py to zip production ready code. #97

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions zip.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import zipfile
import os

files_to_zip = ['requirements.txt', 'main.py']

output_zip_filename = 'deploy.zip'

# Create a ZipFile object in write mode
with zipfile.ZipFile(output_zip_filename, 'w', zipfile.ZIP_DEFLATED) as zipf:
for file_to_zip in files_to_zip:
# Check if the file exists in the current directory
if os.path.exists(file_to_zip):
# Add the file to the zip archive
zipf.write(file_to_zip, os.path.basename(file_to_zip))
else:
print(f"Warning: {file_to_zip} not found in the current directory.")

print(f"Files {', '.join(files_to_zip)} have been zipped to {output_zip_filename}")