Spaces:
Runtime error
Runtime error
Update app.py
Browse files
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 |
-
|
| 34 |
|
| 35 |
-
# Save the selected article's
|
| 36 |
-
st.session_state['
|
|
|
|
| 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 |
-
#
|
| 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:
|