The solution is:
On the client side form:
import anvil.media
def button_download_click(self, **event_args):
anvil.media.download(anvil.server.call('make_zip', path'))
On the server side:
import anvil.media
import shutil
@anvil.server.callable
def make_zip(path):
my_zip = shutil.make_archive('Zip_file_name', 'zip', f'/tmp/{path}')
tmp_file = anvil.media.from_file(f'{my_zip}', 'text/plain')
return tmp_file
This should make a zip file of a directory in your /tmp file space and download it. (make sure the directory exists before zipping it)