From 2108319f840f89f5eb7c387f1da25ddff2d835a6 Mon Sep 17 00:00:00 2001 From: Etancher <30360093+jahanvir@users.noreply.github.com> Date: Sun, 3 Sep 2023 17:21:38 +0530 Subject: [PATCH] added zip.py to zip production ready code. --- zip.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 zip.py diff --git a/zip.py b/zip.py new file mode 100644 index 00000000..3ff57dff --- /dev/null +++ b/zip.py @@ -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}")