feat: add search query endpoint

This commit is contained in:
2026-01-31 15:12:31 +00:00
parent 777060420c
commit d0d45fb8b0
2 changed files with 17 additions and 1 deletions

View File

@@ -75,6 +75,19 @@ def word_frequencies():
return jsonify({"error": f"Malformed or missing data: {str(e)}"}), 400
except Exception as e:
return jsonify({"error": f"An unexpected error occurred: {str(e)}"}), 500
@app.route('/stats/search', methods=["POST"])
def search_dataset():
if stat_obj is None:
return jsonify({"error": "No data uploaded"}), 400
data = request.get_json(silent=True) or {}
if "query" not in data:
return stat_obj.df
query = data["query"]
return jsonify(stat_obj.get_events_containing(query).to_dict(orient='records')), 200
if __name__ == "__main__":
app.run(debug=True)