示例#1
0
def feeds_download(feed_id):
    if feed_id is None or feed_id == "all":
        feeds = Feed.get_all_feeds()
        print(feeds)
    else:
        feeds = Feed.get_feed_by_id(feed_id)

    articles_list = []
    for feed in feeds:
        articles = download_articles(feed.url, feed.id)
        articles_list += articles
    if feed_id != "all":
        return dict(articles_list=articles_list)
    else:
        return "".join(articles_list)
示例#2
0
def feeds_index():
    form = AddFeedForm()
    if AddFeedForm().validate_on_submit():
        Feed.add_feed(form.data["name"], form.data["url"])
        flash("Feed has been added", "success")
    return dict(feeds=Feed.get_all_feeds(), form=form)
示例#3
0
def feeds_articles(feed_id):
    if feed_id is None:
        articles = Article.get_last_articles()
    else:
        articles = Article.get_articles_by_feed_id(feed_id)
    return dict(articles=articles, feeds=Feed.get_all_feeds())