Skip to content
This repository has been archived by the owner on Jun 13, 2023. It is now read-only.

Commit

Permalink
Add remove all and download all files
Browse files Browse the repository at this point in the history
  • Loading branch information
fullonic committed Feb 21, 2020
1 parent 9e3307e commit c0ab3f3
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 3 deletions.
15 changes: 15 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,13 @@ def downloads():
return render_template("download.html", zip_files=zip_files)


@app.route("/downloads/all")
def download_all():
all_zipped = shutil.make_archive(app.config["ZIP_FOLDER"], "zip", app.config["ZIP_FOLDER"])
print(f"{all_zipped=}")
return send_from_directory(Path(all_zipped).parent, Path(all_zipped).name)


@app.route("/get_file/<file_>", methods=["GET"])
def get_file(file_):
"""Download a zip file based on file name."""
Expand All @@ -344,6 +351,14 @@ def remove_file(file_):
return redirect(url_for("downloads"))


@app.route("/remove_file/all", methods=["GET"])
def remove_all_files():
"""Delete a zip file based on file name."""
for f in Path(app.config["ZIP_FOLDER"]).glob("*.zip"):
delete_zip_file(f)
return redirect(url_for("downloads"))


@app.route("/settings", methods=["POST", "GET"])
def settings():
save_config_to_file(request.form.to_dict())
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions templates/_download_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
<td>{{ file.name }}</td>
<td>{{ file.created }}</td>
<td>{{ file.size }} MB</td>
<td><a href="{{ url_for('get_file', file_=file.name)}}" class="badge badge-success mr-2">Descarregar</a>
<a href="{{ url_for('remove_file', file_=file.name)}}" class="badge badge-danger">Eliminar</a></td>
<td><a href="{{ url_for('get_file', file_=file.name)}}" class="badge badge-success mr-2">Descarregar</a></td>
<td><a href="{{ url_for('remove_file', file_=file.name)}}" class="badge badge-danger">Eliminar</a></td>
</tr>
3 changes: 2 additions & 1 deletion templates/download.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
<th scope="col">Nom de l'arxiu</th>
<th scope="col">Data</th>
<th scope="col">Mida</th>
<th scope="col"></th>
<th scope="col"> <a href="{{ url_for('download_all') }}" class="badge badge-success mr-2">Descàrregar Tot</a></th>
<th scope="col"> <a href="{{ url_for('remove_all_files') }}" class="badge badge-danger">Eliminar Tot</a></th>
</tr>
</thead>
<tbody>
Expand Down

0 comments on commit c0ab3f3

Please sign in to comment.