Anne314159 commited on
Commit
b763acd
·
verified ·
1 Parent(s): bbd33b5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -4
app.py CHANGED
@@ -26,14 +26,16 @@ def fetch_news(topic):
26
  def page_trending_niche():
27
  st.title("What is trending in my niche?")
28
  niche = st.text_input('Enter your niche', 'Technology')
 
29
  if niche:
30
  news_items = fetch_news(niche)
31
  article_titles = [item['title'] for item in news_items]
32
  selected_article = st.selectbox("Select an article to generate a social media post about:", article_titles)
33
- selected_article_url = next((item['url'] for item in news_items if item['title'] == selected_article), None)
34
 
35
- # Save the selected article's URL in the session state to use in another page
36
- st.session_state['selected_article_url'] = selected_article_url
 
37
  for item in news_items:
38
  st.write(f"**Title:** {item['title']}")
39
  st.write(f"**Published Date:** {item['published_date']}")
@@ -59,7 +61,7 @@ def generate_social_media_post(description):
59
  def page_social_media_generator():
60
  st.title("Social Media Content Generator")
61
 
62
- # Retrieve the description saved in the session state on the trending niche page
63
  description = st.session_state.get('selected_article_description', '')
64
 
65
  if description:
 
26
  def page_trending_niche():
27
  st.title("What is trending in my niche?")
28
  niche = st.text_input('Enter your niche', 'Technology')
29
+ # page_trending_niche function
30
  if niche:
31
  news_items = fetch_news(niche)
32
  article_titles = [item['title'] for item in news_items]
33
  selected_article = st.selectbox("Select an article to generate a social media post about:", article_titles)
34
+ selected_article_description = next((item['description'] for item in news_items if item['title'] == selected_article), None)
35
 
36
+ # Save the selected article's description in the session state to use in another page
37
+ st.session_state['selected_article_description'] = selected_article_description
38
+
39
  for item in news_items:
40
  st.write(f"**Title:** {item['title']}")
41
  st.write(f"**Published Date:** {item['published_date']}")
 
61
  def page_social_media_generator():
62
  st.title("Social Media Content Generator")
63
 
64
+ # page_social_media_generator function
65
  description = st.session_state.get('selected_article_description', '')
66
 
67
  if description: