Refactoring of the counter code

This commit is contained in:
guimoz 2017-04-13 19:20:34 +02:00
parent 28109eb586
commit d3ff2419aa
2 changed files with 4 additions and 7 deletions

View File

@ -71,13 +71,10 @@ def home_page():
context = {}
with magneticod_db:
cur = magneticod_db.execute(
"SELECT"
" count(id) "
"FROM torrents ;")
context["counter"] = cur.fetchall()
cur = magneticod_db.execute("SELECT count() FROM torrents ;")
n_torrents = cur.fetchone()[0]
return flask.render_template("homepage.html",**context)
return flask.render_template("homepage.html",n_torrents=n_torrents)
@app.route("/torrents/")

View File

@ -17,7 +17,7 @@
</main>
<footer>
<div>Now with {{counter[0][0]}} torrents available !</div>
Now with {{n_torrents}} torrents available !
</footer>
</body>
</html>