From 0cef259ecc3f3405a68ecefa6187c2e721e4052e Mon Sep 17 00:00:00 2001 From: Nathan Woodburn Date: Mon, 7 Oct 2024 17:39:25 +1100 Subject: [PATCH] feat: Add now page rss --- server.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/server.py b/server.py index 63d01c7..1c3c9ad 100644 --- a/server.py +++ b/server.py @@ -632,6 +632,25 @@ def now_old(): "now/old.html", handshake_scripts=handshake_scripts, now_pages=html ) +@app.route("/now.rss") +def now_rss(): + host = request.scheme + "://" + request.host + print(host) + # Generate RSS feed + now_pages = os.listdir("templates/now") + now_pages = [ + page for page in now_pages if page != "template.html" and page != "old.html" + ] + now_pages.sort(reverse=True) + rss = f'Nathan.Woodburn/{host}See what I\'ve been up toen-us{datetime.datetime.now(tz=datetime.timezone.utc).strftime("%a, %d %b %Y %H:%M:%S %z")}' + for page in now_pages: + link = page.strip(".html") + date = datetime.datetime.strptime(link, "%y_%m_%d") + date = date.strftime("%A, %B %d, %Y") + rss += f'{date}{host}/now/{link}{date}{host}/now/{link}' + rss += "" + return make_response(rss, 200, {"Content-Type": "application/rss+xml"}) + # endregion