|
|
|
import flask_apscheduler
|
|
|
|
from flask import Blueprint, Flask, request
|
|
|
|
|
|
|
|
from app import create_app
|
|
|
|
from scheduler.schedule_text import schedule_text
|
|
|
|
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_post():
|
|
|
|
return schedule_text(request)
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
APP.run()
|