def export_ctf(): backup = export_ctf_util() ctf_name = ctf_config.ctf_name() day = datetime.datetime.now().strftime("%Y-%m-%d") full_name = u"{}.{}.zip".format(ctf_name, day) return send_file( backup, cache_timeout=-1, as_attachment=True, attachment_filename=full_name )
def export_ctf(path=None): with app.app_context(): backup = export_ctf_util() if path: with open(path, "wb") as target: shutil.copyfileobj(backup, target) else: name = ctf_name() day = datetime.datetime.now().strftime("%Y-%m-%d_%T") full_name = f"{name}.{day}.zip" with open(full_name, "wb") as target: shutil.copyfileobj(backup, target) print(f"Exported {full_name}")