Exceptionhandling, underpay warning
This commit is contained in:
22
app.py
22
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')
|
@@ -84,14 +84,14 @@
|
||||
<button type="submit" name="wert" value="-2" class="btn btn-xl btn-primary custom-btn-size-med">🧾</button>
|
||||
</div>
|
||||
</td>
|
||||
<td class="bold-row">🪙 {{ change }}€</td>
|
||||
<td class="bold-row {{ background }}">🪙 {{ change }}€</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3"><button type="submit" name="wert" value="0" id="reset" class="btn btn-xl btn-dark custom-btn-size">Reset 🦭</button></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3">Made with ♥️, marmalade and zero kowledge in Kiel Strawberry City.<br>
|
||||
Version: 1.0.2/2024-05-26<br>
|
||||
Version: 1.0.3/2024-05-27<br>
|
||||
<a href="https://gitea.elpatron.me/elpatron/erdbeerhannah/src/branch/main/README.md" target="_blank">Weitere Infos</a></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
Reference in New Issue
Block a user