Refactoring of the counter code
This commit is contained in:
parent
28109eb586
commit
d3ff2419aa
@ -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/")
|
||||||
|
@ -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>
|
||||||
|
Loading…
Reference in New Issue
Block a user