crunk-scheduler/start.py

34 lines
629 B
Python

import flask_apscheduler
from flask import request
from app import create_app
from scheduler.schedule_text import schedule_post
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():
return "crunk-scheduler online!"
@APP.route("/schedule", methods=["POST"])
def schedule():
return schedule_post(request)
if __name__ == "__main__":
APP.run()