From: Claromes Date: Sat, 4 Nov 2023 12:51:17 +0000 (-0300) Subject: fix json response X-Git-Url: https://git.claromes.com/?a=commitdiff_plain;h=0aaa936d28545b68e19ebc7c455671289a2bd7f7;p=waybacktweets.git fix json response --- 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)