summaryrefslogtreecommitdiff
path: root/jimbrella/web.py
blob: 006c66cc0f52a39ae1cba81b3cfa17707c7e2d4e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from flask import Flask, request, render_template
from .database import Database
from .utils import group_by_status, find_overdue
from .config import *

db = Database(DATABASE_PATH)

app = Flask("jimbrella")


@app.route("/")
def index():
    umbrellas = db.read()
    statuses = group_by_status(umbrellas)
    return render_template(
        "index.html",
        total=len(umbrellas),
        available=len(statuses["available"]),
        lent=len(statuses["lent"]),
        overdue=len(find_overdue(umbrellas)),
    )


if __name__ == "__main__":
    app.run()