Adds a counter of indexed torrents on the homepage

This commit is contained in:
guimoz 2017-04-12 21:06:59 +02:00
parent f9cb28f31a
commit 28109eb586
3 changed files with 24 additions and 3 deletions

View File

@ -67,7 +67,17 @@ def requires_auth(f):
@app.route("/")
@requires_auth
def home_page():
return flask.render_template("homepage.html")
magneticod_db = get_magneticod_db()
context = {}
with magneticod_db:
cur = magneticod_db.execute(
"SELECT"
" count(id) "
"FROM torrents ;")
context["counter"] = cur.fetchall()
return flask.render_template("homepage.html",**context)
@app.route("/torrents/")

View File

@ -21,3 +21,10 @@ main form input {
main > div {
margin-right: 0.5em;
}
footer {
margin-top: 0.833em;
display: flex;
justify-content: space-between;
}

View File

@ -15,5 +15,9 @@
<input type="search" name="search" placeholder="Search the BitTorrent DHT" autofocus>
</form>
</main>
<footer>
<div>Now with {{counter[0][0]}} torrents available !</div>
</footer>
</body>
</html>