diff --git a/feedtools.py b/feedtools.py index c1b97f9..e2dc973 100644 --- a/feedtools.py +++ b/feedtools.py @@ -39,7 +39,6 @@ def update(): tmp['all_posts_sorted'][str(post_date)].append(post) db.update(tmp) - return db def load(): db = SimpleDatabase('feeds.json', 'feeds.log') diff --git a/requirements.txt b/requirements.txt index e5a1bbe..90fe8cd 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ flask feedparser pathlib +Flask-APScheduler \ No newline at end of file diff --git a/start.py b/start.py index 0bb4e7f..c5448f9 100644 --- a/start.py +++ b/start.py @@ -1,4 +1,5 @@ import flask +import flask_apscheduler import feedtools import json @@ -7,6 +8,19 @@ APP = flask.Flask(__name__, static_folder="static", template_folder="templates") +# Initialize Flask-APScheduler +# https://github.com/viniciuschiele/flask-apscheduler +# Thanks Crunk for pointing to this extention! +scheduler = flask_apscheduler.APScheduler() +scheduler.api_enabled = False +scheduler.init_app(APP) +scheduler.start() + +@scheduler.task('interval', id='update', minutes=10) +def update(): + print('Updating the Multifeeder!') + feedtools.update() + @APP.route("/") def index(): db = feedtools.load() diff --git a/templates/index.html b/templates/index.html index fcd5d79..d9fc02e 100644 --- a/templates/index.html +++ b/templates/index.html @@ -2,7 +2,7 @@
-The following feeds are rendered in the Multifeeder. The feeds in this list include streams of projects and activities in and around Varia.
+The following feeds are rendered in the Multifeeder. The feeds in this list include streams of projects and activities in and around Varia. The API is updated every 10 minutes.
{% for x, feed in db['feeds'].items() %}