def sources_post(): feed_url = request.form['feed'] # create new Feed object from feed_url try: feed_obj = Feed(feed_url) source = Source.insert_from_feed(feed_url, feed_obj.get_source()) # retrieve articles from the rss feed added by the form feed_articles = feed_obj.get_articles() Article.insert_from_feed(source.id, feed_articles) except: flash("Invalid Feed") return redirect('/sources')
def update_source(src): src_obj = Feed(src.feed) feed_articles = src_obj.get_articles() # insert the articles into the db Article.insert_from_feed(src.id, feed_articles) print('Updated ' + src.feed)