File size: 3,954 Bytes
d00d00a
 
fd76e44
d00d00a
 
 
6354ec7
d00d00a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6354ec7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d00d00a
 
 
 
 
 
 
 
 
 
 
6354ec7
 
d00d00a
 
 
 
 
 
 
6354ec7
 
 
 
 
 
d00d00a
 
 
 
 
 
6354ec7
 
 
 
 
 
 
 
 
 
 
 
d00d00a
 
 
 
 
 
 
 
719cc14
 
 
 
aca3173
d00d00a
aca3173
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
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)