diff --git a/app.py b/app.py index 20c66d3..3f57f2b 100644 --- a/app.py +++ b/app.py @@ -17,10 +17,11 @@ item3 = 0 item4 = 0 item5 = 0 item6 = 0 +background = "bg-white" @app.route("/", methods=["GET", "POST"]) def index(): - global gesamtwert, item1, item2, item3, item4, item5, item6, sum, givenfloat, change, given + global gesamtwert, item1, item2, item3, item4, item5, item6, sum, givenfloat, change, given, background if request.method == "POST": # wert = float(request.form["wert"]) @@ -41,6 +42,7 @@ def index(): item4 = 0 item5 = 0 item6 = 0 + background = "bg-white" # summarize value elif wertfloat != -2: gesamtwert += wertfloat @@ -62,10 +64,17 @@ def index(): if wertfloat == .2: item6 += 1 if givenfloat > 0: - gesamtwert = session['summefloat'] - sum = str(gesamtwert) + "0" - change = str(round((givenfloat - gesamtwert) * -1, 2)) + "0" - logging.info('Sum %s, given %s, change %s', sum, givenfloat, change) + try: + gesamtwert = session['summefloat'] or 0 + sum = str(gesamtwert) + "0" + change = str(round((givenfloat - gesamtwert) * -1, 2)) + "0" + logging.info('Sum %s, given %s, change %s', sum, givenfloat, change) + except: + logging.warning("Failed to read sum") + if givenfloat - gesamtwert < 0: + background = "bg-danger" + else: + background = "bg-white" session['item1'] = item1 session['item2'] = item2 @@ -87,6 +96,7 @@ def index(): item4=session.get('item4', 0), item5=session.get('item5', 0), item6=session.get('item6', 0), + background=background, ) @app.route('/favicon.ico') @@ -100,5 +110,5 @@ def favicon(): # 'about.html') if __name__ == "__main__": - logging.info('Starting erdbeerhannah v1.0.2') + logging.info('Starting erdbeerhannah v1.0.3') app.run(debug=True, host='0.0.0.0') \ No newline at end of file diff --git a/templates/index.html b/templates/index.html index c2fd471..807a401 100644 --- a/templates/index.html +++ b/templates/index.html @@ -84,14 +84,14 @@ - 🪙 {{ change }}€ + 🪙 {{ change }}€ Made with ♥️, marmalade and zero kowledge in Kiel Strawberry City.
- Version: 1.0.2/2024-05-26
+ Version: 1.0.3/2024-05-27
Weitere Infos