I'm currently building cherry py app for my projects and at certain function I need auto starting download a file.
After zip file finish generating, I want to start downloading to client So after images are created, they are zipped and sent to client
class Process(object):
exposed = True
def GET(self, id, norm_all=True, format_ramp=None):
...
def content(): #generating images
...
def zipdir(basedir, archivename):
assert os.path.isdir(basedir)
with closing(ZipFile(archivename, "w", ZIP_DEFLATED)) as z:
for root, dirs, files in os.walk(basedir):
#NOTE: ignore empty directories
for fn in files:
absfn = os.path.join(root, fn)
zfn = absfn[len(basedir)+len(os.sep):] #XXX: relative path
z.write(absfn, zfn)
zipdir("/data/images/8","8.zip")
#after zip file finish generating, I want to start downloading to client
#so after images are created, they are zipped and sent to client
#and I'm thinking do it here, but don't know how
return content()
GET._cp_config = {'response.stream': True}
def POST(self):
global proc
global processing
proc.kill()
processing = False