Get census data based on the question
()
| 5 | |
| 6 | @plugin.route('get_census_data', methods=['GET']) |
| 7 | def get_census_data_get(): |
| 8 | """ |
| 9 | Get census data based on the question |
| 10 | """ |
| 11 | |
| 12 | question = request.args.get('question') |
| 13 | if not question: |
| 14 | return jsonify({ |
| 15 | "error": "question is missing from the request args" |
| 16 | }) |
| 17 | |
| 18 | raw_table_json = requests.post('https://text-sql-be.onrender.com/api/get_tables', json={"natural_language_query": question}) |
| 19 | |
| 20 | print('raw table: ', raw_table_json.json()) |
| 21 | |
| 22 | newJson = { |
| 23 | **raw_table_json.json(), |
| 24 | "natural_language_query": question, |
| 25 | } |
| 26 | |
| 27 | print('new json: ', newJson) |
| 28 | |
| 29 | final_res = requests.post('https://text-sql-be.onrender.com/api/text_to_sql', json=newJson) |
| 30 | |
| 31 | print('final res: ', final_res.json()) |
| 32 | |
| 33 | parsed = final_res.json() |
| 34 | |
| 35 | resultsData = parsed['result']['results'] |
| 36 | sqlData = parsed['sql_query'] |
| 37 | |
| 38 | return jsonify({ |
| 39 | "answer": resultsData, |
| 40 | "sql_query": sqlData, |
| 41 | }) |
| 42 | |
| 43 | |
| 44 | plugin_config = Blueprint('plugin_config', __name__) |
nothing calls this directly
no outgoing calls
no test coverage detected