aggregator / app.py
ntdservices's picture
Update app.py
719cc14 verified
from flask import Flask, render_template
import feedparser
import os
app = Flask(__name__)
# Expanded RSS news feeds – U.S., government, and international
rss_urls = [
# US National
"https://rss.nytimes.com/services/xml/rss/nyt/HomePage.xml",
"https://rss.nytimes.com/services/xml/rss/nyt/World.xml",
"https://rss.nytimes.com/services/xml/rss/nyt/US.xml",
"https://feeds.npr.org/1001/rss.xml",
"https://www.cbsnews.com/latest/rss/main",
"https://abcnews.go.com/abcnews/topstories",
"https://www.nbcnews.com/id/3032091/device/rss/rss.xml",
"https://rss.cnn.com/rss/edition.rss",
"https://feeds.foxnews.com/foxnews/latest",
"https://www.wsj.com/xml/rss/3_7085.xml", # WSJ World
"https://www.washingtontimes.com/rss/headlines/news/",
"https://www.latimes.com/local/rss2.0.xml",
"https://www.politico.com/rss/politics08.xml",
"https://www.theatlantic.com/feed/all/",
"https://www.axios.com/rss",
"https://www.vox.com/rss/index.xml",
"https://www.propublica.org/feeds/articles.xml",
"https://www.oann.com/feed/",
"https://www.newsmax.com/rss/",
# U.S. Government and Agencies
"https://www.whitehouse.gov/briefing-room/feed/",
"https://www.fbi.gov/news/stories/rss.xml",
"https://www.justice.gov/opa/newsroom/rss.xml",
"https://www.dhs.gov/news/feeds",
"https://www.nasa.gov/rss/dyn/breaking_news.rss",
"https://www.defense.gov/DesktopModules/ArticleCS/RSS.ashx?ContentType=1&Site=105&max=10",
"https://www.state.gov/rss-feed-the-latest/",
"https://www.cisa.gov/news.xml",
"https://www.cdc.gov/media/rss.htm",
"https://www.nih.gov/news-events/news-releases/rss.xml",
"https://www.congress.gov/rss/most-viewed.xml",
# International
"https://www.theguardian.com/world/rss",
"https://www.theguardian.com/us-news/rss",
"https://www.reutersagency.com/feed/?best-sectors=general-news&post_type=best",
"https://feeds.bbci.co.uk/news/world/rss.xml",
"https://feeds.bbci.co.uk/news/rss.xml",
"https://globalnews.ca/feed/",
"https://english.alarabiya.net/.mrss/en.xml",
"https://www.france24.com/en/rss",
"https://www.dw.com/en/top-stories/s-9097",
"https://rss.dw.com/rdf/rss-en-all",
"https://www.rferl.org/api/zmgp_qe$op",
"https://www.hindustantimes.com/rss/topnews/rssfeed.xml",
"https://timesofindia.indiatimes.com/rssfeedstopstories.cms",
"https://japantoday.com/category/national/rss",
"https://www.smh.com.au/rss/feed.xml",
"https://www.abc.net.au/news/feed/51120/rss.xml",
"https://www.aljazeera.com/xml/rss/all.xml",
"https://www.scmp.com/rss/91/feed", # South China Morning Post
# Tech / Science
"https://rss.slashdot.org/Slashdot/slashdot",
"https://feeds.arstechnica.com/arstechnica/index/",
"https://www.theverge.com/rss/index.xml",
"https://rss.app/feeds/k8MKfNsFvfcvK3sT.xml", # Bloomberg Top News
]
# Fetch RSS feed
def get_rss_articles():
articles = []
for url in rss_urls:
try:
feed = feedparser.parse(url)
for entry in feed.entries:
articles.append({
"title": entry.title,
"link": entry.link,
"summary": entry.get("summary", ""),
"published": entry.get("published", ""),
"source": url
})
except Exception as e:
print(f"Error fetching {url}: {e}")
return articles
# Routes
@app.route("/")
def index():
articles = get_rss_articles()
return render_template("index.html", articles=articles)
@app.route("/api/ping")
def ping():
return "pong", 200
# ─────────────────── main ────────────────────────────
if __name__ == "__main__":
port = int(os.environ.get("PORT", 7860))
app.run(host="0.0.0.0", port=port)