Multifeeding RSS streams into points of access.
https://multi.vvvvvvaria.org/
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.
83 lines
1.8 KiB
83 lines
1.8 KiB
import flask
|
|
import flask_apscheduler
|
|
import feedtools
|
|
import json
|
|
|
|
APP = flask.Flask(__name__,
|
|
static_url_path="",
|
|
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()
|
|
template = flask.render_template(
|
|
"index.html",
|
|
db=db,
|
|
)
|
|
return template
|
|
|
|
@APP.route("/feeds/latest/<num>")
|
|
def latest(num):
|
|
feed = feedtools.latest(num)
|
|
if flask.request.values.get("format") == 'md':
|
|
response_data = feedtools.md(feed)
|
|
mimetype_data = 'text/plain'
|
|
else:
|
|
response_data = json.dumps(feed)
|
|
mimetype_data = 'application/json'
|
|
|
|
return APP.response_class(
|
|
response=response_data,
|
|
status=200,
|
|
mimetype=mimetype_data
|
|
)
|
|
|
|
@APP.route("/feeds/today")
|
|
def today():
|
|
feed = feedtools.today()
|
|
if flask.request.values.get("format") == 'md':
|
|
response_data = feedtools.md(feed)
|
|
mimetype_data = 'text/plain'
|
|
else:
|
|
response_data = json.dumps(feed)
|
|
mimetype_data = 'application/json'
|
|
return APP.response_class(
|
|
response=response_data,
|
|
status=200,
|
|
mimetype=mimetype_data
|
|
)
|
|
|
|
@APP.route("/feeds/past/<days>")
|
|
def past(days):
|
|
feed = feedtools.past(days)
|
|
if flask.request.values.get("format") == 'md':
|
|
response_data = feedtools.md(feed)
|
|
mimetype_data = 'text/plain'
|
|
else:
|
|
response_data = json.dumps(feed)
|
|
mimetype_data = 'application/json'
|
|
return APP.response_class(
|
|
response=response_data,
|
|
status=200,
|
|
mimetype=mimetype_data
|
|
)
|
|
|
|
if __name__ == "__main__":
|
|
feedtools.update()
|
|
APP.debug = True
|
|
APP.run(port=5678)
|
|
|
|
|