hlydecker commited on
Commit
ebf808d
1 Parent(s): d1c6587

feature: just show posts

Browse files
Files changed (1) hide show
  1. app.py +13 -1
app.py CHANGED
@@ -1,5 +1,6 @@
1
  import gradio as gr
2
  import subprocess
 
3
 
4
  def api_call(input_text):
5
  # Replace 'YOUR_CURL_COMMAND' with the actual cURL command you want to use
@@ -12,7 +13,18 @@ def api_call(input_text):
12
 
13
  try:
14
  response = subprocess.check_output(curl_command, universal_newlines=True)
15
- return response
 
 
 
 
 
 
 
 
 
 
 
16
  except subprocess.CalledProcessError:
17
  return "Error: Unable to fetch data using cURL."
18
 
 
1
  import gradio as gr
2
  import subprocess
3
+ import json
4
 
5
  def api_call(input_text):
6
  # Replace 'YOUR_CURL_COMMAND' with the actual cURL command you want to use
 
13
 
14
  try:
15
  response = subprocess.check_output(curl_command, universal_newlines=True)
16
+ response_data = json.loads(response)
17
+
18
+ # Extract the contents of all posts
19
+ posts_data = response_data.get("included", [])
20
+ post_contents = []
21
+ for post in posts_data:
22
+ if post.get("type") == "post":
23
+ content = post.get("attributes", {}).get("content", {}).get("subject", "")
24
+ if content:
25
+ post_contents.append(content)
26
+
27
+ return "\n".join(post_contents) if post_contents else "No post contents found."
28
  except subprocess.CalledProcessError:
29
  return "Error: Unable to fetch data using cURL."
30