Compare commits

...

40 Commits

Author SHA1 Message Date
1a12dcd1d0 Neue Preise, neue Artikel 2024-06-24 13:52:54 +02:00
elpatron68
9f7bc8086c increase version 2024-05-29 16:15:48 +02:00
elpatron68
833287222d Change price 2024-05-29 16:15:16 +02:00
elpatron68
e2cdaf059a Update README 2024-05-28 16:59:11 +02:00
elpatron68
b2e8192a2d Update README 2024-05-28 12:52:52 +02:00
elpatron68
3a15183094 Instructions 2024-05-28 11:03:48 +02:00
elpatron68
08d668c984 4 decimal places 2024-05-28 08:53:08 +02:00
elpatron68
24e9d83a52 Add load time 2024-05-28 08:42:57 +02:00
elpatron68
4d7e352220 Update README 2024-05-27 21:14:07 +02:00
elpatron68
abc4403373 Cache-Control 2024-05-27 19:10:12 +02:00
elpatron68
57930c374a Cache-Control 2024-05-27 19:09:48 +02:00
elpatron68
9318f0b25c prevent cached responses 2024-05-27 19:01:11 +02:00
elpatron68
02a9df95b5 Add timestamp 2024-05-27 15:46:12 +02:00
elpatron68
9ad4038d6b remove line break 2024-05-27 15:28:24 +02:00
elpatron68
c68fcc56f9 Add some keywords 2024-05-27 15:22:27 +02:00
elpatron68
90eccad3f7 change title 2024-05-27 13:38:29 +02:00
elpatron68
2440963afc Add version 2024-05-27 13:29:42 +02:00
elpatron68
08705ae44e Rename var 2024-05-27 13:27:31 +02:00
elpatron68
a57c5fa837 Add link 2024-05-27 13:20:11 +02:00
elpatron68
7a0be8aa61 Add tooltips 2024-05-27 13:16:18 +02:00
elpatron68
e2383aefb5 Version logging 2024-05-27 12:56:41 +02:00
elpatron68
6601cd3e88 Fix typo 2024-05-27 12:53:46 +02:00
elpatron68
4a1b237482 Fix typo 2024-05-27 12:53:19 +02:00
elpatron68
629ca0ea88 Fix typo 2024-05-27 12:40:15 +02:00
elpatron68
6ff60dfb09 Add donation link 2024-05-27 12:36:28 +02:00
elpatron68
db3f8bd13f White background by default 2024-05-27 12:02:35 +02:00
elpatron68
face097b39 uWSGI log to file 2024-05-27 11:33:14 +02:00
elpatron68
0fd5e9f789 Basic logging for debug purpose 2024-05-27 11:21:57 +02:00
elpatron68
f6acec036a Update keywords 2024-05-27 11:04:24 +02:00
elpatron68
d720848ccb Update README 2024-05-27 11:02:44 +02:00
elpatron68
57a57a8e0a Add meta tags 2024-05-27 10:43:37 +02:00
elpatron68
ff84b5ec40 Exceptionhandling, underpay warning 2024-05-27 10:20:25 +02:00
elpatron68
9050ec7c03 Update README 2024-05-26 14:31:24 +02:00
elpatron68
133d219d6e Add author´s contact 2024-05-26 14:26:16 +02:00
elpatron68
6823be2c0d Update .gitignore 2024-05-26 14:20:35 +02:00
elpatron68
9bfe5b8add Remove __pycache__ 2024-05-26 14:18:53 +02:00
elpatron68
74b4620b69 ls static files 2024-05-26 14:02:23 +02:00
elpatron68
222a8f019e copy all static files 2024-05-26 14:00:31 +02:00
elpatron68
b6d6b62223 Version: 1.0.2 2024-05-26 13:58:46 +02:00
elpatron68
a73261f18a target 2024-05-26 13:57:48 +02:00
6 changed files with 119 additions and 44 deletions

5
.gitignore vendored
View File

@@ -1,2 +1,3 @@
.venv
log
.venv/
log/
__pycache__/

View File

@@ -14,7 +14,8 @@ WORKDIR /app
# copy every content from the local file to the image
COPY ./app.py /app
COPY ./templates/index.html /app/templates/index.html
COPY ./static/favicon.ico /app/static/favicon.ico
COPY ./static/ /app/static/
RUN ls -la /app/static/*
COPY ./app.ini /app
COPY ./wsgi.py /app

View File

@@ -1,18 +1,22 @@
# erdbeerhannah
*Kassen-App für Erdbeerstände*
*Simple Rechner-App für Erdbeerstände (und ähnliche Verkausstellen)*
## Erdbeerkasse
## Motivation
Viele Erdbeerstände in Deutschland haben keine elektronische Kasse. Aufgrund der geringen Zahl unterschiedlicher Artikel bietet sich eine simple Rechner-App an, die bis zu sechs verschiedene Artikel in unterschiedlicher Stückzahl summieren kann.
Viele Erdbeerstände in Deutschland haben keine elektronische Kasse. Aufgrund der geringen Zahl unterschiedlicher Artikel bietet sich diese simple Rechner-App an, die bis zu sechs verschiedene Artikel in unterschiedlicher Stückzahl summieren kann.
Für jeden Artikel gibt es einen großen Knopf. Ein Klick addiert 1x den ausgewählten Artikel zur Gesamtsumme. Optional kann per Eingabefeld das Wechselgeld berechnet werden.
Eine Demo-Instanz der App kann [hier](https://erdbeerhannah.elpatron.me/) zum freien Testen aufgerufen werden.
Eine Demo-Instanz der App kann [hier](https://erdbeerhannah.elpatron.me/) zur freien Nutzung aufgerufen werden.
Die Demo-Instanz ist werbefrei und die Nutzung dauerhaft kostenlos. Details siehe in den Abschnitten *Anpassung* und *Privatsphäre*.
**Der Autor übernimmt keinerlei Haftung für Verfügbarkeit, Funktionalität, insbesondere Richtigkeit der Rechenergebnisse.**
## Design
Die Web-App *erdbeerhannah* wurde für einfachste Bedienbarkeit auf allen Geräten (Notebook, Smartphone, Tablet) entwickelt. Die Bedienung ist intuitiv und erfordert keine Einarbeitung, das Design klar und farblich sinnvoll gestaltet.
Die Web-App *erdbeerhannah* wurde für einfachste Bedienbarkeit auf allen Geräten (Notebook, Smartphone, Tablet) entwickelt. Die Bedienung ist intuitiv und erfordert keine Einarbeitung, das Design ist klar und farblich sinnvoll gestaltet.
![Darstellung im Webbrowser](./static/image-20240526125759295.png)
*Darstellung im Webbrowser*
@@ -25,21 +29,25 @@ Die Web-App *erdbeerhannah* wurde für einfachste Bedienbarkeit auf allen Gerät
## Anpassung der Artikel und Preise
Die Anpassung von Artikeln und Preisen ist derzeit lediglich im Quellcode der App möglich. Die App ist auf maximal sechs Artikel beschränkt.
Die Anpassung von Artikeln und Preisen ist derzeit lediglich im Quellcode der App möglich. Die App ist auf maximal sechs Artikel beschränkt.
Individuelle Anpassungen (Birnen? Kirschen?) oder Branding können auf Wunsch vom Autor gegen ein angemessenes Entgeld oder eine Spende an eine Organisation der Wahl des Autors vorgenommen werden. Ein Hosting unter der eigenen Domain (z.B. https://kasse.mein-erdbeerhof.de) ist ebenfalls möglich.
Individuelle Anpassungen (Birnen? Kirschen? Spargel?) oder ein passendes Branding können auf Wunsch vom Autor gegen ein angemessenes Entgeld oder eine Spende an eine [Organisation der Wahl des Autors](https://www.tagesschau.de/spendenkonten/spendenkonten-133.html) vorgenommen werden. Ein Hosting unter der eigenen Domain (z.B. https://kasse.mein-erdbeerhof.de) ist ebenfalls möglich. Bei Interesse schreiben Sie bitte eine Mail an [m.busche@mailbox.org](mailto:m.busche@mailbox.org?subject=Erdbeerhannah).
## Deployment
Die Bereitstellung der App erfolgt am einfachsten mit Docker:
`git clone https://gitea.elpatron.me/elpatron/erdbeerhannah.git`
`cd erdbeerhannah`
`docker image build -t erdbeerhannah:latest .`
`docker run -p 9090:90 -t erdbeerhannah:latest`
## Privatsphäre
Die App *erdbeerhannah* protokolliert keinerlei Daten. Keine IP-Adressen, keine Klicks, keine Benutzer-Eingaben und auch sonst nichts.
Die App *erdbeerhannah* protokolliert keinerlei Daten. Keine IP-Adressen, keine Klicks, keine Benutzer-Eingaben und auch sonst nichts. Es werden keine Cookies genutzt, es findet kein Tracking statt und es gibt keine Werbung.
## Lizenz
@@ -47,16 +55,15 @@ Die App *erdbeerhannah* protokolliert keinerlei Daten. Keine IP-Adressen, keine
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2024 Markus Busche; Knorrstr. 16, 24106 Kiel, Hermany
Copyright (C) 2024 Markus Busche; Knorrstr. 16, 24106 Kiel, Germany
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. You just DO WHAT THE FUCK YOU WANT TO.
```
0. You just DO WHAT THE FUCK YOU WANT TO.
```

View File

@@ -2,4 +2,5 @@
wsgi-file = wsgi.py
master = 5
http = :90
die-on-term = true
die-on-term = true
logto = /app/log/marmelade.log

68
app.py
View File

@@ -1,12 +1,25 @@
import os
import time
import logging
from flask import Flask, render_template, request, session, send_from_directory
from flask import Flask, render_template, request, session, send_from_directory, g
from flask_bootstrap import Bootstrap
app = Flask(__name__)
app.config['SECRET_KEY'] = 'j69ol5mcHLsEtLg4Y/+myd9wWD4pp56E'
# setup logging
formatter = logging.Formatter(
'%(asctime)s %(levelname)s %(process)d ---- %(threadName)s '
'%(module)s : %(funcName)s {%(pathname)s:%(lineno)d} %(message)s','%Y-%m-%dT%H:%M:%SZ')
handler = logging.StreamHandler()
handler.setFormatter(formatter)
app.logger.setLevel(logging.DEBUG)
app.logger.addHandler(handler)
Bootstrap(app)
version = "1.0.9/2024-05-28"
postcounter = 0
gesamtwert = 0
change = 0
givenfloat = 0
@@ -18,14 +31,36 @@ item4 = 0
item5 = 0
item6 = 0
app.logger.info('Starting erdbeerhannah ' + version)
# https://code-maven.com/flask-display-elapsed-time
@app.before_request
def before_request():
g.request_start_time = time.time()
g.request_time = lambda: "%.4fs" % (time.time() - g.request_start_time)
# prevent cached responses
# https://stackoverflow.com/questions/47376744/how-to-prevent-cached-response-flask-server-using-chrome
@app.after_request
def add_header(r):
"""
Add headers to both force latest IE rendering engine or Chrome Frame,
and also to cache the rendered page for 10 minutes.
"""
r.headers["Cache-Control"] = "no-store, max-age=0"
return r
@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, postcounter, version
background = "bg-white"
if request.method == "POST":
postcounter += 1
# wert = float(request.form["wert"])
wert = request.form.get('wert', "0", type=float)
given = request.form.get('given', "0", type=float)
app.logger.debug('wert: %s, given: %s', wert, given)
wertfloat = float(wert)
givenfloat = float(given)
@@ -41,6 +76,7 @@ def index():
item4 = 0
item5 = 0
item6 = 0
background = "bg-white"
# summarize value
elif wertfloat != -2:
gesamtwert += wertfloat
@@ -49,23 +85,29 @@ def index():
sum = str(gesamtwert) + "0"
# summarize items
if wertfloat == 5.8:
if wertfloat == 4.9:
item1 += 1
if wertfloat == 4.8:
item2 += 1
if wertfloat == 3.3:
item3 += 1
if wertfloat == 8.8:
if wertfloat == 4.5:
item4 += 1
if wertfloat == 5.5:
if wertfloat == 5:
item5 += 1
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"
except:
app.logger.warning("Failed to read sum")
if givenfloat - gesamtwert < 0:
background = "bg-danger"
else:
background = "bg-white"
session['item1'] = item1
session['item2'] = item2
@@ -78,6 +120,9 @@ def index():
session['change'] = change
session['given'] = givenfloat
app.logger.info('*** sum %s, given %s, change %s', sum, givenfloat, change)
app.logger.info('*** postcounter %s', postcounter)
return render_template("index.html", gesamtwert=session.get('summestring', 0),
change=session.get('change', 0),
given=session.get('given', 0),
@@ -87,6 +132,8 @@ def index():
item4=session.get('item4', 0),
item5=session.get('item5', 0),
item6=session.get('item6', 0),
background=background,
version=version,
)
@app.route('/favicon.ico')
@@ -100,5 +147,4 @@ def favicon():
# 'about.html')
if __name__ == "__main__":
logging.info('Starting erdbeerhannah v1.0.1')
app.run(debug=True, host='0.0.0.0')
app.run(debug=True, host='127.0.0.1')

View File

@@ -3,7 +3,22 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Erdbeerkasse 🍓💶</title>
<meta http-equiv="content-Type" content="text/html; utf-8" />
<meta http-equiv="Pragma" content="cache" />
<meta name="robots" content="INDEX,FOLLOW" />
<meta http-equiv="content-Language" content="de" />
<meta name="description" content="Viele Obststände in Deutschland haben keine elektronische Kasse. Aufgrund der geringen Zahl unterschiedlicher Artikel bietet sich diese simple Rechner-App an, die bis zu sechs verschiedene Artikel in unterschiedlicher Stückzahl summieren kann." />
<meta name="keywords" content="rechner kasse calculator bargeld artikel obst erdbeeren spargel kirschen verkaufsstand wechselgeld kostenlos opensource werbefrei" />
<meta name="author" content="Markus Busche" />
<meta name="publisher" content="Markus Busche" />
<meta name="copyright" content="2024 Markus Busche" />
<meta name="audience" content="Alle" />
<meta name="page-type" content="HTML-Formular" />
<meta name="page-topic" content="Dienstleistung" />
<meta http-equiv="Reply-to" content="m.busche@mailbox.org" />
<meta name="expires" content="" />
<meta name="revisit-after" content="2 days" />
<title>erdbeerhannah 🍓💶</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<style>
body, html {
@@ -58,41 +73,45 @@
}
</style>
</head>
<script>
$(document).ready(function(){
$('[data-toggle="tooltip"]').tooltip();
});
</script>
<body>
<div class="container-fluid table-container">
<table class="table table-bordered">
<form method="post">
<tbody>
<tr class="bold-row">
<td colspan="3">Erdbeerkasse 🍓💶</td>
<td colspan="3">erdbeerrechner 🍓💶</td>
</tr>
<tr>
<td><button type="submit" name="wert" value="5.8" class="btn btn-xl btn-primary custom-btn-size">🍓 5,80€ ({{ item1 }})</button></td>
<td><button type="submit" name="wert" value="4.8" class="btn btn-xl btn-danger custom-btn-size">🫙🫙 4,80€ ({{ item2 }})</button></td>
<td><button type="submit" name="wert" value="3.3" class="btn btn-xl btn-danger custom-btn-size">🫙 3,30€ ({{ item3 }})</button></td>
<td><button type="submit" name="wert" value="4.9" data-toggle="tooltip" data-placement="top" title="500g Erdbeeren" class="btn btn-xl btn-primary custom-btn-size">🍓 4,90€ ({{ item1 }})</button></td>
<td><button type="submit" name="wert" value="4.8" data-toggle="tooltip" data-placement="top" title="Marmelade groß" class="btn btn-xl btn-danger custom-btn-size">🫙🫙 4,80€ ({{ item2 }})</button></td>
<td><button type="submit" name="wert" value="3.3" data-toggle="tooltip" data-placement="top" title="Marmelade klein" class="btn btn-xl btn-danger custom-btn-size">🫙 3,30€ ({{ item3 }})</button></td>
</tr>
<tr>
<td><button type="submit" name="wert" value="8.8" class="btn btn-xl btn-warning custom-btn-size">🧃🧃 8,80€ ({{ item4 }})</button></td>
<td><button type="submit" name="wert" value="5.5" class="btn btn-xl btn-warning custom-btn-size">🧃 5,50€ ({{ item5 }})</button></td>
<td><button type="submit" name="wert" value="0.2" class="btn btn-xl btn-success custom-btn-size">🛍️ 0,20€ ({{ item6 }})</button></td>
<td><button type="submit" name="wert" value="5.0" data-toggle="tooltip" data-placement="top" title="500g Kirschen" class="btn btn-xl btn-warning custom-btn-size">🍒 5,00€ ({{ item4 }})</button></td>
<td><button type="submit" name="wert" value="4.5" data-toggle="tooltip" data-placement="top" title="500g Himbeeren" class="btn btn-xl btn-warning custom-btn-size">🫐 4,50€ ({{ item5 }})</button></td>
<td><button type="submit" name="wert" value="0.2" data-toggle="tooltip" data-placement="top" title="Tragetasche" class="btn btn-xl btn-success custom-btn-size">🛍️ 0,20€ ({{ item6 }})</button></td>
</tr>
<tr>
<td class="bold-row">🫰 {{ gesamtwert }}€</td>
<td data-toggle="tooltip" data-placement="top" title="Summe" class="bold-row">🫰 {{ gesamtwert }}€</td>
<td>
<div class="input-container">
<input type="text" class="form-control" name="given" placeholder="{{ given }}">
<button type="submit" name="wert" value="-2" class="btn btn-xl btn-primary custom-btn-size-med">🧾</button>
<button type="submit" name="wert" value="-2" data-toggle="tooltip" data-placement="top" title="Wechselgeld berechnen" class="btn btn-xl btn-primary custom-btn-size-med">🧾</button>
</div>
</td>
<td class="bold-row">🪙 {{ change }}€</td>
<td data-toggle="tooltip" data-placement="top" title="Wechselgeld" 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.1/2024-05-26<br>
<a href="https://gitea.elpatron.me/elpatron/erdbeerhannah/src/branch/main/README.md">Weitere Infos</a></td>
<td colspan="3">Made with ♥️, marmalade and zero knowledge in <a href="https://kiel-sailing-city.de/" target="_blank">Kiel Strawberry City.</a><br>
Version: {{ version }} ({{ g.request_time() }}), <a href="https://gitea.elpatron.me/elpatron/erdbeerhannah/src/branch/main/README.md" target="_blank">Infos</a></td>
</tr>
</tbody>
</form>