Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -3,6 +3,8 @@ import gradio as gr
|
|
3 |
import json
|
4 |
from Data_Fetching_and_Rendering import fetch_and_render_dashboard
|
5 |
from analytics_fetch_and_rendering import fetch_and_render_analytics
|
|
|
|
|
6 |
|
7 |
# Shared state
|
8 |
token_received = {"status": False, "token": None, "client_id": None}
|
@@ -61,6 +63,15 @@ def guarded_fetch_analytics():
|
|
61 |
)
|
62 |
return count_md, plot
|
63 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
# --- Build the Gradio UI ---
|
65 |
with gr.Blocks(theme=gr.themes.Soft(primary_hue="blue", secondary_hue="sky"),
|
66 |
title="LinkedIn Post Viewer & Analytics") as app:
|
@@ -114,6 +125,17 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue="blue", secondary_hue="sky"),
|
|
114 |
outputs=[follower_count, follower_plot]
|
115 |
)
|
116 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
117 |
# Launch the app
|
118 |
if __name__ == "__main__":
|
119 |
app.launch(server_name="0.0.0.0", server_port=7860, share=True)
|
|
|
3 |
import json
|
4 |
from Data_Fetching_and_Rendering import fetch_and_render_dashboard
|
5 |
from analytics_fetch_and_rendering import fetch_and_render_analytics
|
6 |
+
from mentions_dashboard import generate_mentions_dashboard
|
7 |
+
|
8 |
|
9 |
# Shared state
|
10 |
token_received = {"status": False, "token": None, "client_id": None}
|
|
|
63 |
)
|
64 |
return count_md, plot
|
65 |
|
66 |
+
def run_mentions_and_load(comm_token, comm_client_id):
|
67 |
+
try:
|
68 |
+
html_path = generate_mentions_dashboard(comm_client_id, comm_token)
|
69 |
+
with open(html_path, "r", encoding="utf-8") as f:
|
70 |
+
return f.read()
|
71 |
+
except Exception as e:
|
72 |
+
return f"<p style='color:red;'>Failed to load mentions: {e}</p>"
|
73 |
+
|
74 |
+
|
75 |
# --- Build the Gradio UI ---
|
76 |
with gr.Blocks(theme=gr.themes.Soft(primary_hue="blue", secondary_hue="sky"),
|
77 |
title="LinkedIn Post Viewer & Analytics") as app:
|
|
|
125 |
outputs=[follower_count, follower_plot]
|
126 |
)
|
127 |
|
128 |
+
with gr.TabItem("3️⃣ Mentions"):
|
129 |
+
gr.Markdown("Analyze sentiment of recent posts that mention your organization.")
|
130 |
+
fetch_mentions_btn = gr.Button("🧠 Fetch Mentions & Sentiment", variant="primary")
|
131 |
+
mentions_html = gr.HTML(value="<p style='text-align:center; color:#555;'>Waiting for token...</p>")
|
132 |
+
fetch_mentions_btn.click(
|
133 |
+
fn=run_mentions_and_load,
|
134 |
+
inputs=[token_display, client_display],
|
135 |
+
outputs=[mentions_html]
|
136 |
+
)
|
137 |
+
|
138 |
+
|
139 |
# Launch the app
|
140 |
if __name__ == "__main__":
|
141 |
app.launch(server_name="0.0.0.0", server_port=7860, share=True)
|