talexm commited on
Commit
5827073
·
1 Parent(s): 8879cb8
Files changed (1) hide show
  1. app.py +51 -8
app.py CHANGED
@@ -111,18 +111,61 @@ try:
111
  except Exception as e:
112
  news_results[category] = [f"Error fetching news: {str(e)}"]
113
 
114
- # Display Results
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
115
  for category, articles in news_results.items():
116
- st.subheader(f"{category} News")
117
  if articles and "Error fetching news" not in articles[0]:
118
- # Show Actual URLs
119
- for idx, article in enumerate(articles, start=1):
120
- st.markdown(f"{idx}. [**{article}**]({article})") # Display URL as clickable link
121
- else:
122
- st.warning(f"Could not fetch news for **{category}**.")
 
 
 
 
 
 
 
123
  except Exception as e:
124
  st.error(f"An unexpected error occurred: {str(e)}")
125
-
126
  # # Display results
127
  # for category, articles in news_results.items():
128
  # st.write(f"### Top News in {category}:")
 
111
  except Exception as e:
112
  news_results[category] = [f"Error fetching news: {str(e)}"]
113
 
114
+ # Custom Carousel Style
115
+ st.markdown(
116
+ """
117
+ <style>
118
+ .carousel {
119
+ display: flex;
120
+ overflow-x: auto;
121
+ scroll-snap-type: x mandatory;
122
+ gap: 1rem;
123
+ padding: 1rem;
124
+ }
125
+ .carousel-item {
126
+ scroll-snap-align: start;
127
+ flex: none;
128
+ width: 300px;
129
+ background: #f9f9f9;
130
+ border-radius: 10px;
131
+ padding: 1rem;
132
+ box-shadow: 0 2px 10px rgba(0,0,0,0.1);
133
+ }
134
+ .carousel-item h3 {
135
+ margin-bottom: 1rem;
136
+ font-size: 1.25rem;
137
+ color: #333;
138
+ }
139
+ .carousel-item a {
140
+ text-decoration: none;
141
+ color: #007BFF;
142
+ }
143
+ .carousel-item a:hover {
144
+ text-decoration: underline;
145
+ }
146
+ </style>
147
+ <div class="carousel">
148
+ """,
149
+ unsafe_allow_html=True,
150
+ )
151
+
152
+ # Add News Items to the Carousel
153
  for category, articles in news_results.items():
 
154
  if articles and "Error fetching news" not in articles[0]:
155
+ st.markdown(
156
+ f"""
157
+ <div class="carousel-item">
158
+ <h3>{category} News</h3>
159
+ {"".join([f'<p><a href="{article}" target="_blank">{article}</a></p>' for article in articles])}
160
+ </div>
161
+ """,
162
+ unsafe_allow_html=True,
163
+ )
164
+
165
+ # Close the carousel container
166
+ st.markdown("</div>", unsafe_allow_html=True)
167
  except Exception as e:
168
  st.error(f"An unexpected error occurred: {str(e)}")
 
169
  # # Display results
170
  # for category, articles in news_results.items():
171
  # st.write(f"### Top News in {category}:")