fix json response
authorClaromes <claromes@hey.com>
Sat, 4 Nov 2023 12:51:17 +0000 (09:51 -0300)
committerClaromes <claromes@hey.com>
Sat, 4 Nov 2023 12:51:17 +0000 (09:51 -0300)
app.py

diff --git a/app.py b/app.py
index a28477449a967dba34639f4280cc7907701bdf36..16f4d1ece816f9413828a8241abbf0c784dfeea1 100644 (file)
--- a/app.py
+++ b/app.py
@@ -266,7 +266,17 @@ if query or st.session_state.count:
                     response_json = requests.get(link)
                     if response_json.status_code == 200:
                         json_data = response_json.json()
-                        json_text = response_json.json()['text']
+
+                        if 'data' in json_data:
+                            if 'text' in json_data['data']:
+                                json_text = json_data['data']['text']
+                            else:
+                                json_text = json_data['data']
+                        else:
+                            if 'text' in json_data:
+                                json_text = json_data['text']
+                            else:
+                                json_text = json_data
 
                         st.code(json_text)
                         st.json(json_data, expanded=False)