adding flask_apscheduler to update the Multifeeder every 10 minutes
This commit is contained in:
parent
9f5c25ab1b
commit
afa1d8c6d1
@ -39,7 +39,6 @@ def update():
|
|||||||
tmp['all_posts_sorted'][str(post_date)].append(post)
|
tmp['all_posts_sorted'][str(post_date)].append(post)
|
||||||
|
|
||||||
db.update(tmp)
|
db.update(tmp)
|
||||||
return db
|
|
||||||
|
|
||||||
def load():
|
def load():
|
||||||
db = SimpleDatabase('feeds.json', 'feeds.log')
|
db = SimpleDatabase('feeds.json', 'feeds.log')
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
flask
|
flask
|
||||||
feedparser
|
feedparser
|
||||||
pathlib
|
pathlib
|
||||||
|
Flask-APScheduler
|
14
start.py
14
start.py
@ -1,4 +1,5 @@
|
|||||||
import flask
|
import flask
|
||||||
|
import flask_apscheduler
|
||||||
import feedtools
|
import feedtools
|
||||||
import json
|
import json
|
||||||
|
|
||||||
@ -7,6 +8,19 @@ APP = flask.Flask(__name__,
|
|||||||
static_folder="static",
|
static_folder="static",
|
||||||
template_folder="templates")
|
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("/")
|
@APP.route("/")
|
||||||
def index():
|
def index():
|
||||||
db = feedtools.load()
|
db = feedtools.load()
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<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">
|
<link rel="stylesheet" type="text/css" href="/css/stylesheet.css">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
</head>
|
</head>
|
||||||
@ -41,7 +41,7 @@
|
|||||||
</section>
|
</section>
|
||||||
<section id="feeds">
|
<section id="feeds">
|
||||||
<h1>Currently feeding</h1>
|
<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() %}
|
{% for x, feed in db['feeds'].items() %}
|
||||||
<div class="feed el{{ x }}">
|
<div class="feed el{{ x }}">
|
||||||
<div class="title">{{ feed.title }}</div>
|
<div class="title">{{ feed.title }}</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user