addressed the [ERROR] Error: send_file() got an unexpected keyword argument 'path' error

This commit is contained in:
scifijunkie 2024-06-12 19:47:21 +00:00
parent f310930154
commit 1c104320eb

@ -6,9 +6,7 @@ import glob
import pwnagotchi import pwnagotchi
import pwnagotchi.plugins as plugins import pwnagotchi.plugins as plugins
from flask import abort from flask import abort, send_from_directory, render_template_string
from flask import send_from_directory
from flask import render_template_string
TEMPLATE = """ TEMPLATE = """
{% extends "base.html" %} {% extends "base.html" %}
@ -37,11 +35,9 @@ TEMPLATE = """
filter.onkeyup = function() { filter.onkeyup = function() {
document.body.style.cursor = 'progress'; document.body.style.cursor = 'progress';
var table, tr, tds, td, i, txtValue; var li = shakeList.getElementsByTagName("li");
filterVal = filter.value.toUpperCase(); for (var i = 0; i < li.length; i++) {
li = shakeList.getElementsByTagName("li"); var txtValue = li[i].textContent || li[i].innerText;
for (i = 0; i < li.length; i++) {
txtValue = li[i].textContent || li[i].innerText;
if (txtValue.toUpperCase().indexOf(filterVal) > -1) { if (txtValue.toUpperCase().indexOf(filterVal) > -1) {
li[i].style.display = "list-item"; li[i].style.display = "list-item";
} else { } else {
@ -50,7 +46,6 @@ TEMPLATE = """
} }
document.body.style.cursor = 'default'; document.body.style.cursor = 'default';
} }
{% endblock %} {% endblock %}
{% block content %} {% block content %}
@ -58,7 +53,7 @@ TEMPLATE = """
<ul id="list" data-role="listview" style="list-style-type:disc;"> <ul id="list" data-role="listview" style="list-style-type:disc;">
{% for handshake in handshakes %} {% for handshake in handshakes %}
<li class="file"> <li class="file">
<a href="/plugins/handshakes-dl/{{handshake}}">{{handshake}}</a> <a href="/plugins/handshakes-dl/{{ handshake }}">{{ handshake }}</a>
</li> </li>
{% endfor %} {% endfor %}
</ul> </ul>
@ -91,13 +86,12 @@ class HandshakesDL(plugins.Plugin):
return render_template_string(TEMPLATE, return render_template_string(TEMPLATE,
title="Handshakes | " + pwnagotchi.name(), title="Handshakes | " + pwnagotchi.name(),
handshakes=handshakes) handshakes=handshakes)
else: else:
directory = "/home/pi" directory = "/home/pi"
try: try:
file_path = os.path.join(directory, path) file_path = os.path.join(directory, path)
logging.info(f"[HandshakesDL] serving {file_path}") logging.info(f"[HandshakesDL] serving {file_path}")
return send_from_directory(directory=directory, path='.', filename=path, as_attachment=True) return send_from_directory(directory=directory, filename=path, as_attachment=True)
except FileNotFoundError: except FileNotFoundError:
logging.error("File not found") logging.error("File not found")
abort(404) abort(404)