diff --git a/app.py b/app.py
index 1106241..b0d6a66 100644
--- a/app.py
+++ b/app.py
@@ -10,22 +10,12 @@ migrate = Migrate()
def create_app():
APP = Flask(__name__)
- scheduler = flask_apscheduler.APScheduler()
- scheduler.api_enabled = True
- scheduler.init_app(APP)
- scheduler.start()
APP.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///schedule.db"
APP.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
db.init_app(APP)
migrate.init_app(APP, db, render_as_batch=True)
-
create_rss_feed()
-
- @scheduler.task("interval", id="update", minutes=10)
- def update():
- update_rss_feed()
-
return APP
@@ -34,7 +24,6 @@ def create_rss_feed():
fg = FeedGenerator()
fg.id("http://crunk.website")
fg.title("Crunk website")
- fg.author({"name": "John Doe", "email": "john@example.de"})
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")
@@ -43,7 +32,3 @@ def create_rss_feed():
rssfeed = fg.rss_str(pretty=True)
fg.atom_file("static/atom.xml")
fg.rss_file("static/rss.xml")
-
-
-def update_rss_feed():
- print("updating rss feed")
diff --git a/start.py b/start.py
index cd0d5af..47e7e7a 100644
--- a/start.py
+++ b/start.py
@@ -1,10 +1,23 @@
+import flask_apscheduler
from flask import Flask, request
from app import create_app
from scheduler.schedule_text import schedule_text
+from updater import update_rss_feed
APP = create_app()
+scheduler = flask_apscheduler.APScheduler()
+scheduler.api_enabled = False
+scheduler.init_app(APP)
+scheduler.start()
+
+
+@scheduler.task("interval", id="update", minutes=1)
+def update():
+ with APP.app_context():
+ update_rss_feed()
+
@APP.route("/")
def index():
diff --git a/static/atom.xml b/static/atom.xml
index 1c0ee52..812f5ac 100644
--- a/static/atom.xml
+++ b/static/atom.xml
@@ -1,2 +1,2 @@
-http://crunk.websiteCrunk website2023-10-02T19:08:59.272412+00:00John Doejohn@example.depython-feedgenSome things crunk is doing!
\ No newline at end of file
+http://crunk.websiteCrunk website2023-10-03T18:20:53.506614+00:00python-feedgenSome things crunk is doing!
\ No newline at end of file
diff --git a/static/rss.xml b/static/rss.xml
index bf5e2f9..3527120 100644
--- a/static/rss.xml
+++ b/static/rss.xml
@@ -1,2 +1,2 @@
-Crunk websitehttp://crunk.website/test.atomSome things crunk is doing!http://www.rssboard.org/rss-specificationpython-feedgenenMon, 02 Oct 2023 19:08:59 +0000
\ No newline at end of file
+Crunk websitehttp://crunk.website/test.atomSome things crunk is doing!http://www.rssboard.org/rss-specificationpython-feedgenenTue, 03 Oct 2023 18:20:53 +0000
\ No newline at end of file
diff --git a/updater.py b/updater.py
new file mode 100644
index 0000000..1d3d628
--- /dev/null
+++ b/updater.py
@@ -0,0 +1,7 @@
+from models.postmodel import Post
+
+
+def update_rss_feed():
+ posts = Post.query.all()
+ for post in posts:
+ print(post.content)