From 0aaa936d28545b68e19ebc7c455671289a2bd7f7 Mon Sep 17 00:00:00 2001 From: Claromes Date: Sat, 4 Nov 2023 09:51:17 -0300 Subject: [PATCH] fix json response --- app.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/app.py b/app.py index a284774..16f4d1e 100644 --- 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) -- 2.34.1