webapi where you can request scheduled rss feed publishing
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
986 B

from zoneinfo import ZoneInfo
from feedgen.feed import FeedGenerator
from models.postmodel import Post
def update_rss_feed():
fg = create_rss_feed()
zoneinfo = ZoneInfo("Europe/Berlin")
posts = Post.query.all()
for post in posts:
fe = fg.add_entry()
fe.id("http://lernfunk.de/media/654321/1")
fe.title(f"Crunk website:{post.id}")
fe.content(post.content)
fe.published(post.scheduled_time.astimezone(tz=zoneinfo))
fe.link(href="http://crunk.website")
write_rss_feed(fg)
def create_rss_feed():
print("creating rss feed")
fg = FeedGenerator()
fg.id("http://crunk.website")
fg.title("Crunk website")
fg.link(href="http://crunk.website", rel="alternate")
fg.subtitle("Some things crunk is doing!")
fg.link(href="http://crunk.website/test.atom", rel="self")
fg.language("en")
return fg
def write_rss_feed(fg):
fg.atom_file("static/atom.xml")
fg.rss_file("static/rss.xml")