summaryrefslogtreecommitdiff
path: root/jimbrella/web.py
blob: 8b4530992e2ea8fae8138ec9a1baf1fc8cf641cf (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
from flask import Flask, request, render_template
from .database import Database
from .config import *

db = Database(DATABASE_PATH)

app = Flask("jimbrella")


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


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