from flask import Flask, render_template import feedparser import os app = Flask(__name__) # Expanded RSS news feeds – rss_urls = [ # Environment "https://www.theguardian.com/uk/environment/rss", "https://rss.nytimes.com/services/xml/rss/nyt/climate.xml", "https://feeds.bbci.co.uk/news/science_and_environment/rss.xml", "https://e360.yale.edu/feed.xml", "https://www.bbc.co.uk/sn/rss/", "https://news.un.org/feed/subscribe/en/news/topic/climate-change/feed/rss.xml", "https://www.ecowatch.com/feed", "https://factor.niehs.nih.gov/feeds/newsletter.xml", "https://grist.org/feed/", "https://earth911.com/feed/", "https://news.climate.columbia.edu/feed/", "https://www.sciencedaily.com/rss/top/environment.xml", "https://news.climate.columbia.edu/feed/", "https://theecologist.org/whats_new/feed", "https://www.environmentuk.net/index.php?format=feed&type=rss", "https://www.independent.co.uk/climate-change/news/rss", "https://envirotecmagazine.com/feed/", "https://planetsave.com/feed/", "https://environmentalprogress.org/big-news?format=RSS", # Environment2 "https://usgreenchamber.com/feed/", "https://www.seattletimes.com/seattle-news/environment/", "https://feeds.feedburner.com/ConservationInternationalBlog", "http://www.ijdesign.com/blog/feed/", "https://thegrownetwork.com/feed/", "https://www.earthava.com/feed/", "https://blog.plant-for-the-planet.org/feed/", "https://feeds.feedburner.com/CreativeGreenLiving", "https://e2.org/feed/", "https://oceanconservancy.org/blog/feed/", "https://www.congress.gov/rss/most-viewed.xml", # ESG "https://esgtoday.com/feed", "https://esgnews.com/feed", "https://advanceesg.org/feed", "https://jstories.media/feed/en/latest", "https://esgpro.co.uk/feed", "https://practicalesg.com/blogs/feed", "https://www.eco-business.com/feeds/", "https://www.indexologyblog.com/category/sustainability/feed/", "https://www.knowesg.com/rss.xml", "https://www.esginvestor.net/feed/", "https://cse-net.org/feed/", "https://www.esgmark.co.uk/blog?format=rss", "https://esgclarity.com/feed/", "https://theimpactinvestor.com/feed/", "https://www.eyeonesg.com/feed/", "https://esgreview.net/feed/", "https://www.emergingmarketsesg.net/feed/", "https://www.scmp.com/rss/91/feed", # South China Morning Post # ESG2 "https://medium.com/feed/the-esg-advisor", "https://www.msci.com/esg-blog-posts/-/rss/kAOIupnbxkM3/feed", "https://esg-blog.com/feed/", "https://theesginvestor.com/feed/", "https://investor-update.com/category/esg-blog/feed", "https://auctusesg.com/feed/", ] # 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)