Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -29,18 +29,28 @@ def main():
|
|
29 |
# Sidebar: Keyword-based filtering
|
30 |
keyword_filter = st.sidebar.text_input("π Enter a keyword to filter news:", "")
|
31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
# Display news articles
|
33 |
st.header("Latest News Articles")
|
34 |
if st.button("Fetch News"):
|
35 |
if not selected_topics:
|
36 |
-
st.warning("
|
37 |
else:
|
|
|
38 |
articles = []
|
39 |
for topic in selected_topics:
|
40 |
# Fetch news for each topic combined with the keyword
|
41 |
articles.extend(fetch_news(topic, keyword_filter))
|
42 |
|
43 |
if articles:
|
|
|
44 |
for article in articles:
|
45 |
st.subheader(article.get("title", "No Title"))
|
46 |
st.write(article.get("description", "No Description"))
|
@@ -48,7 +58,7 @@ def main():
|
|
48 |
st.write(f"[Read more...]({article.get('url')})")
|
49 |
st.write("---")
|
50 |
else:
|
51 |
-
st.info("No articles found for the selected topics or keyword.")
|
52 |
|
53 |
# Footer
|
54 |
st.sidebar.write("Developed with β€οΈ by your group!")
|
@@ -56,3 +66,4 @@ def main():
|
|
56 |
if __name__ == "__main__":
|
57 |
main()
|
58 |
|
|
|
|
29 |
# Sidebar: Keyword-based filtering
|
30 |
keyword_filter = st.sidebar.text_input("π Enter a keyword to filter news:", "")
|
31 |
|
32 |
+
# Display prompt messages
|
33 |
+
if not selected_topics:
|
34 |
+
st.info("π Please select at least one topic from the sidebar.")
|
35 |
+
elif keyword_filter:
|
36 |
+
st.info(f"π Searching for news on '{', '.join(selected_topics)}' with keyword: '{keyword_filter}'.")
|
37 |
+
else:
|
38 |
+
st.info(f"π Searching for news on '{', '.join(selected_topics)}' without any specific keyword.")
|
39 |
+
|
40 |
# Display news articles
|
41 |
st.header("Latest News Articles")
|
42 |
if st.button("Fetch News"):
|
43 |
if not selected_topics:
|
44 |
+
st.warning("β οΈ You must select at least one topic to fetch news.")
|
45 |
else:
|
46 |
+
st.info("β³ Fetching news articles. Please wait...")
|
47 |
articles = []
|
48 |
for topic in selected_topics:
|
49 |
# Fetch news for each topic combined with the keyword
|
50 |
articles.extend(fetch_news(topic, keyword_filter))
|
51 |
|
52 |
if articles:
|
53 |
+
st.success(f"β
Found {len(articles)} articles!")
|
54 |
for article in articles:
|
55 |
st.subheader(article.get("title", "No Title"))
|
56 |
st.write(article.get("description", "No Description"))
|
|
|
58 |
st.write(f"[Read more...]({article.get('url')})")
|
59 |
st.write("---")
|
60 |
else:
|
61 |
+
st.info("β No articles found for the selected topics or keyword. Try different options.")
|
62 |
|
63 |
# Footer
|
64 |
st.sidebar.write("Developed with β€οΈ by your group!")
|
|
|
66 |
if __name__ == "__main__":
|
67 |
main()
|
68 |
|
69 |
+
|