aboutsummaryrefslogtreecommitdiff
path: root/src/web/views
diff options
context:
space:
mode:
authorCédric Bonhomme <cedric@cedricbonhomme.org>2016-09-20 15:31:12 +0200
committerCédric Bonhomme <cedric@cedricbonhomme.org>2016-09-20 15:31:12 +0200
commit2abfc7c43131e0366137b27b0b75132da6ef6582 (patch)
treecd313c9c1a80fb64508b2e17b660b8108452cbce /src/web/views
parentFew improvemnts for the tag cloud of the user's profile pages. (diff)
downloadnewspipe-2abfc7c43131e0366137b27b0b75132da6ef6582.tar.gz
newspipe-2abfc7c43131e0366137b27b0b75132da6ef6582.tar.bz2
newspipe-2abfc7c43131e0366137b27b0b75132da6ef6582.zip
simple test of a 'popular' page.
Diffstat (limited to 'src/web/views')
-rw-r--r--src/web/views/views.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/web/views/views.py b/src/web/views/views.py
index a7c842d7..c3425a17 100644
--- a/src/web/views/views.py
+++ b/src/web/views/views.py
@@ -1,9 +1,11 @@
import logging
+from collections import Counter
from flask import (request, render_template, flash,
url_for, redirect, current_app)
from flask_babel import gettext
from conf import API_ROOT
+from web.controllers import FeedController
from web.lib.view_utils import etag_match
logger = logging.getLogger(__name__)
@@ -40,6 +42,17 @@ def handle_sqlalchemy_assertion_error(error):
return error.args[0], 400
+@current_app.route('/popular', methods=['GET'])
+@etag_match
+def popular():
+ feeds = FeedController().read().all()
+ counter = Counter()
+ for feed in feeds:
+ counter[feed.link] += 1
+ print(counter.most_common(50))
+ return render_template('popular.html', popular=counter.most_common(50))
+
+
@current_app.route('/about', methods=['GET'])
@etag_match
def about():
bgstack15