diff --git a/proiect-nutritie/Dockerfile b/proiect-nutritie/Dockerfile new file mode 100644 index 0000000..32729d4 --- /dev/null +++ b/proiect-nutritie/Dockerfile @@ -0,0 +1,16 @@ +# Docker va descărca singur Python și Pip în interiorul imaginii +FROM python:3.9-slim + +WORKDIR /app + +# Copiem fișierul de dependințe +COPY requirements.txt . + +# Aici Docker va rula 'pip install' în interiorul lui, nu pe Ubuntu al tău +RUN pip install --no-cache-dir -r requirements.txt + +COPY . . + +EXPOSE 5000 + +CMD ["python", "app/main.py"] \ No newline at end of file diff --git a/proiect-nutritie/app/main.py b/proiect-nutritie/app/main.py new file mode 100644 index 0000000..1eb6634 --- /dev/null +++ b/proiect-nutritie/app/main.py @@ -0,0 +1,49 @@ +from flask import Flask, render_template, request + +import os +# Îi spunem clar că templates este în același folder cu main.py +template_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), 'templates')) +app = Flask(__name__, template_folder=template_dir) + +# Funcția care calculează caloriile (Formula Mifflin-St Jeor) +def calculeaza_target(data): + w = float(data.get('weight')) + h = float(data.get('height')) + a = int(data.get('age')) + gen = data.get('gender') + act = float(data.get('activity')) + scop = data.get('goal') + + # Calcul BMR (Basal Metabolic Rate) + if gen == 'masculin': + bmr = (10 * w) + (6.25 * h) - (5 * a) + 5 + else: + bmr = (10 * w) + (6.25 * h) - (5 * a) - 161 + + # TDEE (Total Daily Energy Expenditure) + tdee = bmr * act + + # Ajustare în funcție de scop (slăbire/îngrășare) + if scop == 'slabire': + return round(tdee - 500) + elif scop == 'ingrasare': + return round(tdee + 500) + else: + return round(tdee) + +@app.route('/') +def index(): + return render_template('index.html') + +@app.route('/calculate', methods=['POST']) +def calculate(): + try: + data = request.form + kcal_final = calculeaza_target(data) + # Trimitem rezultatul înapoi în pagina index.html + return render_template('index.html', rezultat=kcal_final, date_introduse=data) + except Exception as e: + return f"A apărut o eroare: {e}", 400 + +if __name__ == '__main__': + app.run(host='0.0.0.0', port=5000) \ No newline at end of file diff --git a/proiect-nutritie/app/templates/index.html b/proiect-nutritie/app/templates/index.html new file mode 100644 index 0000000..574f614 --- /dev/null +++ b/proiect-nutritie/app/templates/index.html @@ -0,0 +1,64 @@ + + + + + Nutriție AI Pro + + + +
+

Calculator Kcal & AI Menu

+ +
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+ +
+ + {% if rezultat %} +
+

Ținta ta: {{ rezultat }} kcal / zi

+
+
+
🤖 Cere meniu de la AI (Beta)
+ + + {% endif %} +
+
+ + \ No newline at end of file diff --git a/proiect-nutritie/requirements.txt b/proiect-nutritie/requirements.txt new file mode 100644 index 0000000..8ab6294 --- /dev/null +++ b/proiect-nutritie/requirements.txt @@ -0,0 +1 @@ +flask \ No newline at end of file