Browse Source

adding flask_apscheduler to update the Multifeeder every 10 minutes

master
manetta 3 years ago
parent
commit
afa1d8c6d1
  1. 1
      feedtools.py
  2. 1
      requirements.txt
  3. 14
      start.py
  4. 4
      templates/index.html

1
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')

1
requirements.txt

@ -1,3 +1,4 @@
flask
feedparser
pathlib
Flask-APScheduler

14
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()

4
templates/index.html

@ -2,7 +2,7 @@
<html>
<head>
<meta charset="utf-8">
<title>multifeeder</title>
<title>-mu-l-t-i-f-e-e-d-e-r-</title>
<link rel="stylesheet" type="text/css" href="/css/stylesheet.css">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
@ -41,7 +41,7 @@
</section>
<section id="feeds">
<h1>Currently feeding</h1>
<p>The following feeds are rendered in the Multifeeder. The feeds in this list include streams of projects and activities in and around Varia.</p>
<p>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.</p>
{% for x, feed in db['feeds'].items() %}
<div class="feed el{{ x }}">
<div class="title">{{ feed.title }}</div>

Loading…
Cancel
Save