Skip to content

Instantly share code, notes, and snippets.

@lapshinmr
Created August 23, 2017 10:41
Show Gist options
  • Select an option

  • Save lapshinmr/0547dd36c77898205238aef450f7ce4f to your computer and use it in GitHub Desktop.

Select an option

Save lapshinmr/0547dd36c77898205238aef450f7ce4f to your computer and use it in GitHub Desktop.

Revisions

  1. lapshinmr created this gist Aug 23, 2017.
    3 changes: 3 additions & 0 deletions flask_send_file
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@
    return send_file(BytesIO(open(z.filename, 'rb').read()),
    attachment_filename=curdir_basename + '.zip',
    as_attachment=True)
    5 changes: 5 additions & 0 deletions zip_files
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    import zipfile

    with zipfile.ZipFile(os.path.join(curdir, curdir_basename + '.zip'), 'w') as z:
    for f_path in [a_path, w_path, q_path]:
    z.write(f_path, os.path.basename(f_path))