Addressing errors

Addressed the "Internal Server Error The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application." error.
Addressed the "[ERROR] Error: send_from_directory() missing 1 required positional argument: 'path'" error.
This commit is contained in:
scifijunkie 2024-04-22 18:02:11 +00:00
parent a92916d2b0
commit 9ee3278a62

View File

@ -87,15 +87,20 @@ class HandshakesDL(plugins.Plugin):
if path == "/" or not path: if path == "/" or not path:
handshakes = glob.glob(os.path.join("/home/pi", "*.pcap")) handshakes = glob.glob(os.path.join("/home/pi", "*.pcap"))
handshakes = [os.path.basename(path)[:-5] for path in handshakes] handshakes = [os.path.basename(handshake) for handshake in handshakes]
return render_template_string(TEMPLATE, return render_template_string(TEMPLATE,
title="Handshakes | " + pwnagotchi.name(), title="Handshakes | " + pwnagotchi.name(),
handshakes=handshakes) handshakes=handshakes)
else: else:
dir = "/home/pi" directory = "/home/pi"
try: try:
logging.info(f"[HandshakesDL] serving {dir}/{path}.pcap") file_path = os.path.join(directory, path)
return send_from_directory(directory=dir, filename=path+'.pcap', as_attachment=True) logging.info(f"[HandshakesDL] serving {file_path}")
return send_from_directory(directory=directory, path='.', filename=path, as_attachment=True)
except FileNotFoundError: except FileNotFoundError:
logging.error("File not found")
abort(404) abort(404)
except Exception as e:
logging.error(f"Error: {e}")
abort(500)