Compare commits
27 Commits
Author | SHA1 | Date | |
---|---|---|---|
8e0ec494cb
|
|||
9d42a46b43
|
|||
95fa775c61
|
|||
f8b54f7bba
|
|||
9d6555af82
|
|||
3d6c071233
|
|||
6ede84955c
|
|||
b9b7c6b48d
|
|||
d1280eea7b
|
|||
c403e4f253
|
|||
d3e624b9ce
|
|||
86c8b76736 | |||
c85b68b072 | |||
c8648788d0 | |||
fe5ad6ba8d | |||
512e89205c | |||
dbb99ba47a | |||
9c42e0fc63 | |||
92508a23ae | |||
8c3155434a | |||
777ad92b22 | |||
708ce6dd3d | |||
75b66806a2 | |||
6b5c3c36ca | |||
7f90ad4c05 | |||
9dee350323 | |||
c3c3b4f83d |
@ -1,4 +1,4 @@
|
||||
FROM python:3.12-alpine3.19
|
||||
FROM python:3.12-alpine3.21
|
||||
|
||||
ARG APP_DIR="/opt/app"
|
||||
ARG VERSION_ID1="x"
|
||||
|
39
src/Run.py
39
src/Run.py
@ -1,4 +1,6 @@
|
||||
from flask import Flask, request, render_template, jsonify, redirect, url_for, g
|
||||
from flask_session import Session
|
||||
import redis
|
||||
import sqlite3
|
||||
from flask_oidc import OpenIDConnect
|
||||
from werkzeug.middleware.proxy_fix import ProxyFix
|
||||
@ -11,15 +13,21 @@ from math import ceil, floor
|
||||
app = Flask(__name__)
|
||||
app.config.update({
|
||||
'SECRET_KEY': os.environ['SECRET'],
|
||||
'DEBUG': False,
|
||||
'DEBUG': True,
|
||||
'OIDC_CLIENT_SECRETS': json.loads(os.environ['CLIENT_SECRETS']),
|
||||
'OIDC_ID_TOKEN_COOKIE_SECURE': False,
|
||||
'OIDC_ID_TOKEN_COOKIE_SECURE': True,
|
||||
'OIDC_USER_INFO_ENABLED': True,
|
||||
'OIDC_OPENID_REALM': 'hottis',
|
||||
'OIDC_SCOPES': ['openid', 'email', 'profile']
|
||||
'OIDC_SCOPES': ['openid', 'email'],
|
||||
'SESSION_TYPE': 'redis',
|
||||
'SESSION_PERMANENT': False,
|
||||
'SESSION_USE_SIGNER': True,
|
||||
'SESSION_KEY_PREFIX': 'nutri',
|
||||
'SESSION_REDIS': redis.StrictRedis(host='redis-master.redis.svc.cluster.local', port=6379, db=4)
|
||||
})
|
||||
|
||||
oidc = OpenIDConnect(app)
|
||||
logging.basicConfig(level=logging.DEBUG)
|
||||
app.logger.handlers = logging.getLogger('gunicorn.error').handlers
|
||||
|
||||
datapw = 'dasrtwegdffgtewrt4335wferg'
|
||||
@ -73,14 +81,14 @@ def schulrunden(zahl, stellen=0, ist_kcal=False):
|
||||
|
||||
# Index-Route
|
||||
@app.route('/')
|
||||
@oidc.require_login
|
||||
# @oidc.require_login
|
||||
def index():
|
||||
return render_template('index.html')
|
||||
|
||||
# ...
|
||||
|
||||
@app.route('/get_products')
|
||||
@oidc.require_login
|
||||
# @oidc.require_login
|
||||
def get_products():
|
||||
try:
|
||||
conn = psycopg2.connect()
|
||||
@ -95,7 +103,7 @@ def get_products():
|
||||
|
||||
# Route zum Hinzufügen und Berechnen von Lebensmitteln
|
||||
@app.route('/add_lm', methods=['GET'])
|
||||
@oidc.require_login
|
||||
# @oidc.require_login
|
||||
def add_lm():
|
||||
food = request.args.get('food')
|
||||
weight = float(request.args.get('weight'))
|
||||
@ -125,7 +133,7 @@ def convert_decimal(value):
|
||||
|
||||
|
||||
@app.route('/add_nutrition', methods=['POST'])
|
||||
@oidc.accept_token(['openid'])
|
||||
# @oidc.accept_token(['openid'])
|
||||
def add_nutrition():
|
||||
app.logger.info("add_nutrition")
|
||||
|
||||
@ -155,18 +163,18 @@ def add_nutrition():
|
||||
|
||||
|
||||
@app.route('/nutrition')
|
||||
@oidc.require_login
|
||||
# @oidc.require_login
|
||||
def nutrition():
|
||||
return render_template('nutrition.html')
|
||||
|
||||
@app.route('/get_token')
|
||||
@oidc.require_login
|
||||
# @oidc.require_login
|
||||
def get_token():
|
||||
return jsonify(token=oidc.get_access_token())
|
||||
|
||||
|
||||
@app.route('/get_database_entries')
|
||||
@oidc.require_login
|
||||
# @oidc.require_login
|
||||
def get_database_entries():
|
||||
try:
|
||||
# Ersetzen Sie diese Werte mit Ihren Datenbank-Verbindungsinformationen
|
||||
@ -197,7 +205,7 @@ def get_database_entries():
|
||||
|
||||
|
||||
@app.route('/delete_nutrition', methods=['POST'])
|
||||
@oidc.accept_token(['openid'])
|
||||
# @oidc.accept_token(['openid'])
|
||||
def delete_nutrition():
|
||||
data = request.get_json()
|
||||
foodNames = data['foodNames']
|
||||
@ -219,6 +227,13 @@ def delete_nutrition():
|
||||
conn.close()
|
||||
|
||||
|
||||
@app.route('/random')
|
||||
@oidc.require_login
|
||||
def random_page():
|
||||
# Diese Route gibt die HTML-Seite 'random.html' zurück
|
||||
return render_template('random.html')
|
||||
|
||||
|
||||
exposed_app = ProxyFix(app, x_for=1, x_host=1)
|
||||
|
||||
|
||||
#
|
||||
|
@ -20,3 +20,6 @@ requests==2.31.0
|
||||
typing_extensions==4.9.0
|
||||
urllib3==2.1.0
|
||||
Werkzeug==3.0.1
|
||||
Flask-Session
|
||||
redis
|
||||
|
||||
|
BIN
src/static/images/elisa.jpg
Normal file
BIN
src/static/images/elisa.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 64 KiB |
BIN
src/static/images/elo.jpg
Normal file
BIN
src/static/images/elo.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 256 KiB |
BIN
src/static/images/marie.jpg
Normal file
BIN
src/static/images/marie.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 56 KiB |
BIN
src/static/images/marie2.jpg
Normal file
BIN
src/static/images/marie2.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 167 KiB |
@ -241,3 +241,27 @@ button#cancel-button:not(:disabled):hover {
|
||||
.form-row {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
|
||||
button#submit-button {
|
||||
background-image: url('images/elisa.jpg'); /* Pfad zum Bild */
|
||||
background-size: contain; /* Passt das Bild innerhalb des Buttons an, ohne es zu strecken */
|
||||
background-repeat: no-repeat; /* Verhindert das Wiederholen des Bildes */
|
||||
background-position: center; /* Zentriert das Bild im Button */
|
||||
color: transparent; /* Macht den Text unsichtbar, damit nur das Bild sichtbar ist */
|
||||
width: 62px; /* Setzt die Breite automatisch entsprechend des Inhalts */
|
||||
height: 85px; /* Passt die Höhe an, um das Bild vollständig anzuzeigen */
|
||||
padding: 10px 20px; /* Hinzufügen von etwas Platz um das Bild */
|
||||
}
|
||||
|
||||
button#remove-button {
|
||||
background-image: url('images/marie2.jpg'); /* Pfad zum Bild */
|
||||
background-size: contain; /* Passt das Bild innerhalb des Buttons an, ohne es zu strecken */
|
||||
background-repeat: no-repeat; /* Verhindert das Wiederholen des Bildes */
|
||||
background-position: center; /* Zentriert das Bild im Button */
|
||||
color: transparent; /* Macht den Text unsichtbar, damit nur das Bild sichtbar ist */
|
||||
width: 78px; /* Setzt die Breite automatisch entsprechend des Inhalts */
|
||||
height: 85px; /* Passt die Höhe an, um das Bild vollständig anzuzeigen */
|
||||
padding: 10px 20px; /* Hinzufügen von etwas Platz um das Bild */
|
||||
}
|
||||
|
||||
|
@ -301,7 +301,7 @@ function updateTotalNutrition() {
|
||||
</tr>
|
||||
<!-- Zeilen werden hier dynamisch hinzugefügt -->
|
||||
</table>
|
||||
<button id="remove-button" onclick="removeSelectedRow()" disabled>Entfernen</button>
|
||||
<button id="remove-button" onclick="removeSelectedRow()" disabled></button>
|
||||
<table id="total-nutrition-table">
|
||||
<tr>
|
||||
<th>Lebensmittel</th>
|
||||
|
@ -172,7 +172,9 @@
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function openImagePage() {
|
||||
window.open('random', '_blank'); // Öffnet die neue Seite in einem neuen Tab
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
@ -215,6 +217,10 @@
|
||||
|
||||
<div class="search-container">
|
||||
<input type="text" id="search-input" placeholder="Lebensmittel suchen..." oninput="filterTable()">
|
||||
<button onclick="openImagePage()" style="background-image: url('../static/images/marie.jpg'); border: none; cursor: pointer; background-size: cover; width: 62px; height: 85px; vertical-align: middle;">
|
||||
<!-- Der Text wird durch den transparenten Text ersetzt, falls nötig -->
|
||||
<span style="opacity: 0;">Öffnen</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
|
||||
|
10
src/templates/random.html
Normal file
10
src/templates/random.html
Normal file
@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Bildansicht</title>
|
||||
</head>
|
||||
<body style="margin: 0; padding: 0; display: flex; justify-content: center; align-items: center; height: 100vh;">
|
||||
<img src="../static/images/elo.jpg" alt="Elo Bild" style="max-width: 100%; max-height: 100%;">
|
||||
</body>
|
||||
</html>
|
Reference in New Issue
Block a user