GuglielmoTor commited on
Commit
b8b7e00
·
verified ·
1 Parent(s): d0c3617

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -11
app.py CHANGED
@@ -64,15 +64,8 @@ def guarded_fetch_analytics():
64
  return count_md, plot
65
 
66
  def run_mentions_and_load():
67
- try:
68
- html_path = generate_mentions_dashboard(
69
- token_received["client_id"],
70
- token_received["token"]
71
- )
72
- with open(html_path, "r", encoding="utf-8") as f:
73
- return f.read()
74
- except Exception as e:
75
- return f"<p style='color:red;'>Failed to load mentions: {e}</p>"
76
 
77
 
78
  # --- Build the Gradio UI ---
@@ -131,14 +124,16 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue="blue", secondary_hue="sky"),
131
  with gr.TabItem("3️⃣ Mentions"):
132
  gr.Markdown("Analyze sentiment of recent posts that mention your organization.")
133
  fetch_mentions_btn = gr.Button("🧠 Fetch Mentions & Sentiment", variant="primary")
134
- mentions_html = gr.HTML(value="<p style='text-align:center; color:#555;'>Waiting for token...</p>")
 
135
  fetch_mentions_btn.click(
136
  fn=run_mentions_and_load,
137
  inputs=[],
138
- outputs=[mentions_html]
139
  )
140
 
141
 
 
142
  # Launch the app
143
  if __name__ == "__main__":
144
  app.launch(server_name="0.0.0.0", server_port=7860, share=True)
 
64
  return count_md, plot
65
 
66
  def run_mentions_and_load():
67
+ html, fig = generate_mentions_dashboard(comm_client_id, comm_token_dict)
68
+ return html, fig
 
 
 
 
 
 
 
69
 
70
 
71
  # --- Build the Gradio UI ---
 
124
  with gr.TabItem("3️⃣ Mentions"):
125
  gr.Markdown("Analyze sentiment of recent posts that mention your organization.")
126
  fetch_mentions_btn = gr.Button("🧠 Fetch Mentions & Sentiment", variant="primary")
127
+ mentions_html = gr.HTML()
128
+ mentions_plot = gr.Plot(visible=True)
129
  fetch_mentions_btn.click(
130
  fn=run_mentions_and_load,
131
  inputs=[],
132
+ outputs=[mentions_html, mentions_plot]
133
  )
134
 
135
 
136
+
137
  # Launch the app
138
  if __name__ == "__main__":
139
  app.launch(server_name="0.0.0.0", server_port=7860, share=True)