diff options
Diffstat (limited to 'jimbrella')
-rw-r--r-- | jimbrella/config.py | 1 | ||||
-rw-r--r-- | jimbrella/templates/index.html | 23 | ||||
-rw-r--r-- | jimbrella/utils.py | 6 | ||||
-rw-r--r-- | jimbrella/web.py | 25 |
4 files changed, 55 insertions, 0 deletions
diff --git a/jimbrella/config.py b/jimbrella/config.py new file mode 100644 index 0000000..53dd2bb --- /dev/null +++ b/jimbrella/config.py @@ -0,0 +1 @@ +DATABASE_PATH = "/home/fkfd/p/jimbrella/jimbrella.db.csv" diff --git a/jimbrella/templates/index.html b/jimbrella/templates/index.html new file mode 100644 index 0000000..0304499 --- /dev/null +++ b/jimbrella/templates/index.html @@ -0,0 +1,23 @@ +<!DOCTYPE html> +<html> + <head> + <title>JI Umbrella</title> + </head> + <body> + <h1>JI Umbrella Overview</h1> + <table> + <tr> + <td>Total</td> + <td>Available</td> + <td>Lent</td> + <td>Overdue</td> + </tr> + <tr> + <td>{{ total }}</td> + <td>{{ available }}</td> + <td>{{ lent }}</td> + <td>{{ overdue }}</td> + </tr> + </table> + </body> +</html> diff --git a/jimbrella/utils.py b/jimbrella/utils.py new file mode 100644 index 0000000..a9f4623 --- /dev/null +++ b/jimbrella/utils.py @@ -0,0 +1,6 @@ +def group_by_status(umbrellas: list) -> dict: + keys = set([umb["status"] for umb in umbrellas]) + statuses = {} + for key in keys: + statuses[key] = [umb for umb in umbrellas if umb["status"] == key] + return statuses diff --git a/jimbrella/web.py b/jimbrella/web.py new file mode 100644 index 0000000..6446329 --- /dev/null +++ b/jimbrella/web.py @@ -0,0 +1,25 @@ +from flask import Flask, request, render_template +from .database import Database +from .utils import group_by_status +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="Not Yet Implemented", + ) + + +if __name__ == "__main__": + app.run() |