These are some code snippets that I occasionally use. Not much be learnt from this section.
In memory zip creation
Sometimes it is necessary to combine files into a zip without actually storing them. One example could be to put a screenshot along with some legal text. In order to achieve this in python from io import BytesIO from zipfile import ZipFile def create_archive(file_name: str, content: bytes) -> ZipFile: archive = BytesIO() with ZipFile(archive, 'w') as zip_file: with zip_file.open(file_name, 'w') as f: f.write(content) return zip_file archive can be returned via flask with a specified name:...