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.
49 lines
1.3 KiB
49 lines
1.3 KiB
import flask_apscheduler
|
|
from feedgen.feed import FeedGenerator
|
|
from flask import Flask
|
|
from flask_migrate import Migrate
|
|
from flask_sqlalchemy import SQLAlchemy
|
|
|
|
db = SQLAlchemy()
|
|
migrate = Migrate()
|
|
|
|
|
|
def create_app():
|
|
APP = Flask(__name__)
|
|
scheduler = flask_apscheduler.APScheduler()
|
|
scheduler.api_enabled = True
|
|
scheduler.init_app(APP)
|
|
scheduler.start()
|
|
APP.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///schedule.db"
|
|
APP.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
|
|
|
|
db.init_app(APP)
|
|
migrate.init_app(APP, db, render_as_batch=True)
|
|
|
|
create_rss_feed()
|
|
|
|
@scheduler.task("interval", id="update", minutes=10)
|
|
def update():
|
|
update_rss_feed()
|
|
|
|
return APP
|
|
|
|
|
|
def create_rss_feed():
|
|
print("creating rss feed")
|
|
fg = FeedGenerator()
|
|
fg.id("http://crunk.website")
|
|
fg.title("Crunk website")
|
|
fg.author({"name": "John Doe", "email": "john@example.de"})
|
|
fg.link(href="http://crunk.website", rel="alternate")
|
|
fg.subtitle("Some things crunk is doing!")
|
|
fg.link(href="http://crunk.website/test.atom", rel="self")
|
|
fg.language("en")
|
|
atomfeed = fg.atom_str(pretty=True)
|
|
rssfeed = fg.rss_str(pretty=True)
|
|
fg.atom_file("static/atom.xml")
|
|
fg.rss_file("static/rss.xml")
|
|
|
|
|
|
def update_rss_feed():
|
|
print("updating rss feed")
|
|
|