From 8372aa727864a73db1a8f62228b3c539cbc37a29 Mon Sep 17 00:00:00 2001 From: Dylan De Faoite Date: Tue, 17 Mar 2026 13:36:41 +0000 Subject: [PATCH] feat(api): add endpoint to view entire dataset --- server/app.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/server/app.py b/server/app.py index 3ba9295..7a5dea0 100644 --- a/server/app.py +++ b/server/app.py @@ -523,7 +523,28 @@ def get_interaction_analysis(dataset_id): except Exception as e: print(traceback.format_exc()) return jsonify({"error": f"An unexpected error occurred"}), 500 + +@app.route("/dataset//all", methods=["GET"]) +@jwt_required() +def get_full_dataset(dataset_id: int): + try: + user_id = int(get_jwt_identity()) + if not dataset_manager.authorize_user_dataset(dataset_id, user_id): + raise NotAuthorisedException( + "This user is not authorised to access this dataset" + ) + dataset_content = dataset_manager.get_dataset_content(dataset_id) + return jsonify(dataset_content.to_dict(orient="records")), 200 + except NotAuthorisedException: + return jsonify({"error": "User is not authorised to access this content"}), 403 + except NonExistentDatasetException: + return jsonify({"error": "Dataset does not exist"}), 404 + except ValueError as e: + return jsonify({"error": f"Malformed or missing data"}), 400 + except Exception as e: + print(traceback.format_exc()) + return jsonify({"error": f"An unexpected error occurred"}), 500 if __name__ == "__main__": app.run(debug=True)