From 5dc9414d9fe790142545b233dcd02d1c355d0ca0 Mon Sep 17 00:00:00 2001 From: Frederick Yin Date: Tue, 19 Oct 2021 21:06:52 +0800 Subject: Flask web server prototype --- jimbrella/web.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 jimbrella/web.py (limited to 'jimbrella/web.py') 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() -- cgit v1.2.3