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 = {} context = {}
with magneticod_db: with magneticod_db:
cur = magneticod_db.execute( cur = magneticod_db.execute("SELECT count() FROM torrents ;")
"SELECT" n_torrents = cur.fetchone()[0]
" count(id) "
"FROM torrents ;")
context["counter"] = cur.fetchall()
return flask.render_template("homepage.html",**context) return flask.render_template("homepage.html",n_torrents=n_torrents)
@app.route("/torrents/") @app.route("/torrents/")

View File

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