Compare commits
11 Commits
Author | SHA1 | Date | |
---|---|---|---|
5cfba1c068 | |||
09a670727f | |||
f4a4597223
|
|||
70815f0172
|
|||
e4e8e19466 | |||
2228f0cfb5 | |||
24fb1c2941
|
|||
cc3a6381d5
|
|||
938562b9d8
|
|||
103d60764b
|
|||
8a446b8a8d
|
@ -7,9 +7,12 @@ COPY start.sh ${APP_DIR}/
|
||||
|
||||
WORKDIR ${APP_DIR}
|
||||
|
||||
RUN pip install -r requirements.txt
|
||||
RUN \
|
||||
apk add --no-cache build-base libpq-dev && \
|
||||
pip install -r requirements.txt
|
||||
|
||||
EXPOSE 8080
|
||||
|
||||
CMD "./start.sh"
|
||||
|
||||
|
||||
|
@ -28,7 +28,7 @@ def calculate_nutrition(food, weight):
|
||||
|
||||
with conn.cursor() as cursor:
|
||||
# Abfrage der Nährwertdaten aus der Datenbank
|
||||
cursor.execute('SELECT kcal, EW, Fett, KH, BST, CA FROM nutrition_table WHERE name = ?', (food,))
|
||||
cursor.execute('SELECT kcal, EW, Fett, KH, BST, CA FROM nutrition_table WHERE name = %s', (food,))
|
||||
|
||||
result = cursor.fetchone()
|
||||
|
||||
@ -115,8 +115,9 @@ def add_nutrition():
|
||||
try:
|
||||
conn = psycopg2.connect()
|
||||
with conn.cursor() as cursor:
|
||||
cursor.execute("INSERT INTO nutrition_table (name, kcal, ew, fett, kh, bst, ca) VALUES (?, ?, ?, ?, ?, ?, ?)",
|
||||
(food, kcal, ew, fett, kh, bst, ca))
|
||||
cursor.execute("INSERT INTO nutrition_table (name, kcal, ew, fett, kh, bst, ca) VALUES (%s, %s, %s, %s, %s, %s, %s)",
|
||||
(food, kcal, ew, fett, kh, bst, ca))
|
||||
|
||||
|
||||
return redirect(url_for('nutrition'))
|
||||
finally:
|
||||
|
@ -13,6 +13,8 @@ itsdangerous==2.1.2
|
||||
Jinja2==3.1.3
|
||||
MarkupSafe==2.1.4
|
||||
packaging==23.2
|
||||
psycopg==3.1.17
|
||||
psycopg2==2.9.9
|
||||
pycparser==2.21
|
||||
requests==2.31.0
|
||||
typing_extensions==4.9.0
|
||||
|
BIN
src/static/images/favicon.ico
Normal file
BIN
src/static/images/favicon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 13 KiB |
@ -121,3 +121,27 @@ tr:hover:not(.selected) {
|
||||
padding: 20px;
|
||||
margin: 20px 0;
|
||||
}
|
||||
|
||||
|
||||
#nutrition-input-table {
|
||||
width: 100%; /* Tabelle nimmt die volle Breite ein */
|
||||
border-collapse: collapse; /* Entfernt doppelte Ränder */
|
||||
}
|
||||
|
||||
#nutrition-input-table th, #nutrition-input-table td {
|
||||
border: 1px solid #ddd; /* Fügt Ränder hinzu */
|
||||
padding: 8px; /* Fügt Innenabstand hinzu */
|
||||
text-align: left; /* Ausrichtung des Textes */
|
||||
}
|
||||
|
||||
#nutrition-input-table input {
|
||||
width: 100%; /* Eingabefelder nehmen die volle Breite der Zelle ein */
|
||||
box-sizing: border-box; /* Box-Modell für die Breitenberechnung */
|
||||
}
|
||||
|
||||
@media screen and (max-width: 600px) {
|
||||
#nutrition-input-table {
|
||||
display: block;
|
||||
overflow-x: auto; /* Ermöglicht horizontales Scrollen auf kleinen Bildschirmen */
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@
|
||||
<meta charset="UTF-8">
|
||||
<title>Nährwertberechnungs-App</title>
|
||||
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='style.css') }}">
|
||||
<link rel="shortcut icon" href="../static/images/favicon.ico">
|
||||
|
||||
<script>
|
||||
|
||||
|
@ -4,6 +4,8 @@
|
||||
<meta charset="UTF-8">
|
||||
<title>Neue Lebensmittel hinzufügen</title>
|
||||
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='style.css') }}">
|
||||
<link rel="shortcut icon" href="../static/images/favicon.ico">
|
||||
|
||||
<script>
|
||||
function updateSubmitButtonState() {
|
||||
const inputs = document.querySelectorAll('#nutrition-form input');
|
||||
@ -62,13 +64,13 @@
|
||||
<th>CA</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><input type="text" name="food" oninput="updateSubmitButtonState()"></td>
|
||||
<td><input <input type="text" name="kcal" pattern="\d+(\.\d{1,2})?" oninput="updateSubmitButtonState()"></td>
|
||||
<td><input <input type="text" name="ew" pattern="\d+(\.\d{1,2})?" oninput="updateSubmitButtonState()"></td>
|
||||
<td><input <input type="text" name="fett" pattern="\d+(\.\d{1,2})?" oninput="updateSubmitButtonState()"></td>
|
||||
<td><input <input type="text" name="kh" pattern="\d+(\.\d{1,2})?" oninput="updateSubmitButtonState()"></td>
|
||||
<td><input <input type="text" name="bst" pattern="\d+(\.\d{1,2})?" oninput="updateSubmitButtonState()"></td>
|
||||
<td><input <input type="text" name="ca" pattern="\d+(\.\d{1,2})?" oninput="updateSubmitButtonState()"></td>
|
||||
<td><input type="text" name="food" placeholder="Lebensmittel" oninput="updateSubmitButtonState()"></td>
|
||||
<td><input <input type="text" name="kcal" pattern="\d+(\.\d{1,2})?" placeholder="g" oninput="updateSubmitButtonState()"></td>
|
||||
<td><input <input type="text" name="ew" pattern="\d+(\.\d{1,2})?" placeholder="g" oninput="updateSubmitButtonState()"></td>
|
||||
<td><input <input type="text" name="fett" pattern="\d+(\.\d{1,2})?" placeholder="g" oninput="updateSubmitButtonState()"></td>
|
||||
<td><input <input type="text" name="kh" pattern="\d+(\.\d{1,2})?" placeholder="g" oninput="updateSubmitButtonState()"></td>
|
||||
<td><input <input type="text" name="bst" pattern="\d+(\.\d{1,2})?" placeholder="g" oninput="updateSubmitButtonState()"></td>
|
||||
<td><input <input type="text" name="ca" pattern="\d+(\.\d{1,2})?" placeholder="mg" oninput="updateSubmitButtonState()"></td>
|
||||
</tr>
|
||||
</table>
|
||||
<button type="submit" id="submit-button" disabled>Hinzufügen</button>
|
||||
|
Reference in New Issue
Block a user