diff --git a/app/corpora/events.py b/app/corpora/events.py index 932d24db..1a7637bc 100644 --- a/app/corpora/events.py +++ b/app/corpora/events.py @@ -5,6 +5,7 @@ from flask import current_app, request from flask_login import login_required from .CQiWrapper.CQiWrapper import CQiWrapper import logging +import json ''' @@ -36,13 +37,16 @@ def recv_query(message): logger.warning(message) analysis_client = analysis_clients[request.sid] corpus_name = 'CORPUS' - result_subcorpus_name = 'Query-results' # should be set by the user somehow + result_subcorpus_name = 'Query-results' query = message['query'] analysis_client.set_corpus_name(corpus_name) analysis_client.create_attribute_strings() analysis_client.query_subcorpus(result_subcorpus_name, query) results = analysis_client.show_results() logger.warning('Query results: {}'.format(str(results))) + json_results = json.dumps(results) + logger.warning('JSON results are {}'.format(json_results)) + socketio.emit('query_results', json_results) def observe_corpus_analysis_connection(app, corpus_id, session_id): diff --git a/app/templates/corpora/corpus_analysis.html.j2 b/app/templates/corpora/corpus_analysis.html.j2 index a742e919..8bb2f867 100644 --- a/app/templates/corpora/corpus_analysis.html.j2 +++ b/app/templates/corpora/corpus_analysis.html.j2 @@ -81,27 +81,20 @@ socket.on('init_corpus_analysis', function(msg) { +
Query Results - - - - - - - - - - - {% for i in range(0,51) %} - - - - - + {% for hit in json_results %} + {% endfor %}
FirstnameLastnameAge
JillSmith50
EveJackson94