From c9aff27ef064022690f5392d878bd1bcb514478e Mon Sep 17 00:00:00 2001 From: Dylan De Faoite Date: Sun, 1 Feb 2026 16:56:48 +0000 Subject: [PATCH] fix: incorrect error handling in upload and search query routes --- server/app.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/server/app.py b/server/app.py index c926c3c..9af41bc 100644 --- a/server/app.py +++ b/server/app.py @@ -35,12 +35,11 @@ def upload_data(): posts_df = pd.read_json(post_file, lines=True) comments_df = pd.read_json(comment_file, lines=True) stat_obj = StatGen(posts_df, comments_df) + return jsonify({"message": "File uploaded successfully", "event_count": len(stat_obj.df)}), 200 except ValueError as e: return jsonify({"error": f"Failed to read JSONL file: {str(e)}"}), 400 except Exception as e: return jsonify({"error": f"An unexpected error occurred: {str(e)}"}), 500 - - return jsonify({"message": "File uploaded successfully", "event_count": len(stat_obj.df)}), 200 @app.route('/stats/content', methods=['GET']) def word_frequencies(): @@ -88,7 +87,7 @@ def search_dataset(): data = request.get_json(silent=True) or {} if "query" not in data: - return stat_obj.df + return jsonify(stat_obj.df.to_dict(orient="records")), 200 query = data["query"] filtered_df = stat_obj.search(query)