0
현재 프로젝트를위한 체리 파이 응용 프로그램을 만들고 있는데 특정 기능에서 자동 시작 파일을 다운로드해야합니다. 체리 파이 자동 다운로드 파일
은 zip 파일 마감 생성 후, 나는 이미지가 생성되도록 한 후 클라이언트 에 다운로드를 시작하려면, 그들은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