This commit is contained in:
20
src/Run.py
20
src/Run.py
@ -19,7 +19,7 @@ app.config.update({
|
|||||||
'OIDC_SCOPES': ['openid', 'email', 'profile']
|
'OIDC_SCOPES': ['openid', 'email', 'profile']
|
||||||
})
|
})
|
||||||
|
|
||||||
oidc = OpenIDConnect(app)
|
# oidc = OpenIDConnect(app)
|
||||||
app.logger.handlers = logging.getLogger('gunicorn.error').handlers
|
app.logger.handlers = logging.getLogger('gunicorn.error').handlers
|
||||||
|
|
||||||
datapw = 'dasrtwegdffgtewrt4335wferg'
|
datapw = 'dasrtwegdffgtewrt4335wferg'
|
||||||
@ -73,14 +73,14 @@ def schulrunden(zahl, stellen=0, ist_kcal=False):
|
|||||||
|
|
||||||
# Index-Route
|
# Index-Route
|
||||||
@app.route('/')
|
@app.route('/')
|
||||||
@oidc.require_login
|
# @oidc.require_login
|
||||||
def index():
|
def index():
|
||||||
return render_template('index.html')
|
return render_template('index.html')
|
||||||
|
|
||||||
# ...
|
# ...
|
||||||
|
|
||||||
@app.route('/get_products')
|
@app.route('/get_products')
|
||||||
@oidc.require_login
|
# @oidc.require_login
|
||||||
def get_products():
|
def get_products():
|
||||||
try:
|
try:
|
||||||
conn = psycopg2.connect()
|
conn = psycopg2.connect()
|
||||||
@ -95,7 +95,7 @@ def get_products():
|
|||||||
|
|
||||||
# Route zum Hinzufügen und Berechnen von Lebensmitteln
|
# Route zum Hinzufügen und Berechnen von Lebensmitteln
|
||||||
@app.route('/add_lm', methods=['GET'])
|
@app.route('/add_lm', methods=['GET'])
|
||||||
@oidc.require_login
|
# @oidc.require_login
|
||||||
def add_lm():
|
def add_lm():
|
||||||
food = request.args.get('food')
|
food = request.args.get('food')
|
||||||
weight = float(request.args.get('weight'))
|
weight = float(request.args.get('weight'))
|
||||||
@ -125,7 +125,7 @@ def convert_decimal(value):
|
|||||||
|
|
||||||
|
|
||||||
@app.route('/add_nutrition', methods=['POST'])
|
@app.route('/add_nutrition', methods=['POST'])
|
||||||
@oidc.accept_token(['openid'])
|
# @oidc.accept_token(['openid'])
|
||||||
def add_nutrition():
|
def add_nutrition():
|
||||||
app.logger.info("add_nutrition")
|
app.logger.info("add_nutrition")
|
||||||
|
|
||||||
@ -155,18 +155,18 @@ def add_nutrition():
|
|||||||
|
|
||||||
|
|
||||||
@app.route('/nutrition')
|
@app.route('/nutrition')
|
||||||
@oidc.require_login
|
# @oidc.require_login
|
||||||
def nutrition():
|
def nutrition():
|
||||||
return render_template('nutrition.html')
|
return render_template('nutrition.html')
|
||||||
|
|
||||||
@app.route('/get_token')
|
@app.route('/get_token')
|
||||||
@oidc.require_login
|
# @oidc.require_login
|
||||||
def get_token():
|
def get_token():
|
||||||
return jsonify(token=oidc.get_access_token())
|
return jsonify(token=oidc.get_access_token())
|
||||||
|
|
||||||
|
|
||||||
@app.route('/get_database_entries')
|
@app.route('/get_database_entries')
|
||||||
@oidc.require_login
|
# @oidc.require_login
|
||||||
def get_database_entries():
|
def get_database_entries():
|
||||||
try:
|
try:
|
||||||
# Ersetzen Sie diese Werte mit Ihren Datenbank-Verbindungsinformationen
|
# Ersetzen Sie diese Werte mit Ihren Datenbank-Verbindungsinformationen
|
||||||
@ -197,7 +197,7 @@ def get_database_entries():
|
|||||||
|
|
||||||
|
|
||||||
@app.route('/delete_nutrition', methods=['POST'])
|
@app.route('/delete_nutrition', methods=['POST'])
|
||||||
@oidc.accept_token(['openid'])
|
# @oidc.accept_token(['openid'])
|
||||||
def delete_nutrition():
|
def delete_nutrition():
|
||||||
data = request.get_json()
|
data = request.get_json()
|
||||||
foodNames = data['foodNames']
|
foodNames = data['foodNames']
|
||||||
@ -227,4 +227,4 @@ def random_page():
|
|||||||
|
|
||||||
exposed_app = ProxyFix(app, x_for=1, x_host=1)
|
exposed_app = ProxyFix(app, x_for=1, x_host=1)
|
||||||
|
|
||||||
|
#
|
||||||
|
Reference in New Issue
Block a user