add image switch and image delete

This commit is contained in:
2026-01-29 12:35:21 -03:00
parent a6243413a1
commit 5d85dc0714
2 changed files with 150 additions and 13 deletions

View File

@@ -348,6 +348,22 @@ def dataset_list():
def dataset_image(filename):
return send_from_directory(DATASET_DIR, filename)
@app.route("/dataset/images/<filename>", methods=['DELETE'])
def delete_dataset_image(filename):
"""Elimina una imagen del dataset"""
try:
filepath = os.path.join(DATASET_DIR, filename)
if os.path.exists(filepath):
os.remove(filepath)
# Invalidar cache
dataset_cache['timestamp'] = 0
print(f"🗑️ Deleted from dataset: {filename}")
return {"success": True, "message": f"Deleted {filename}"}
else:
return {"success": False, "message": "File not found"}, 404
except Exception as e:
return {"success": False, "message": str(e)}, 500
if __name__ == "__main__":
t = threading.Thread(target=camera_loop, daemon=True)
t.start()