blazingbunny commited on
Commit
ab0640d
·
1 Parent(s): c4b593a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -15
app.py CHANGED
@@ -1,7 +1,7 @@
1
  import streamlit as st
2
  import requests
3
  import json
4
- import pandas as pd
5
 
6
  # Function to fetch data from Google Knowledge Graph
7
  def fetch_data(query, api_key, limit):
@@ -27,20 +27,9 @@ if st.button('Search'):
27
  if api_key:
28
  result = fetch_data(search_query, api_key, output_count)
29
  try:
30
- items = result['itemListElement']
31
- data = []
32
- for item in items:
33
- result_dict = {}
34
- result_item = item['result']
35
- result_dict['Name'] = result_item.get('name', 'N/A')
36
- result_dict['Description'] = result_item.get('description', 'N/A')
37
- result_dict['Detail'] = result_item.get('detailedDescription', {}).get('articleBody', 'N/A')
38
- result_dict['URL'] = result_item.get('url', 'N/A')
39
- data.append(result_dict)
40
-
41
- # Convert list of dictionaries to DataFrame for table display
42
- df = pd.DataFrame(data)
43
- st.table(df)
44
  except:
45
  st.write('No results found.')
46
  else:
 
1
  import streamlit as st
2
  import requests
3
  import json
4
+ import pprint
5
 
6
  # Function to fetch data from Google Knowledge Graph
7
  def fetch_data(query, api_key, limit):
 
27
  if api_key:
28
  result = fetch_data(search_query, api_key, output_count)
29
  try:
30
+ # Pretty-print the entire JSON response to display all outputs
31
+ st.subheader("Full JSON Response")
32
+ st.write(pprint.pformat(result))
 
 
 
 
 
 
 
 
 
 
 
33
  except:
34
  st.write('No results found.')
35
  else: