diff --git a/.gitignore b/.gitignore
index a7f7885a..9dbe163e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -22,4 +22,13 @@ docs/_build/
htmlcov/
.coverage
.coverage.*
-*,cover
\ No newline at end of file
+*,cover
+
+#pycache
+__pycache__/
+
+#credentials
+credentials.py
+
+#chat-history
+chat_history
\ No newline at end of file
diff --git a/application.py b/application.py
index 98546fbb..32b42af9 100644
--- a/application.py
+++ b/application.py
@@ -1,5 +1,5 @@
from datetime import datetime, timedelta
-
+import credentials as c
import bcrypt
import smtplib
import re
@@ -13,6 +13,46 @@
from tabulate import tabulate
from forms import HistoryForm, RegistrationForm, LoginForm, CalorieForm, UserProfileForm, EnrollForm, WorkoutForm
from service import history as history_service
+import openai
+import os
+from utilities import get_response
+import time
+
+# Set the OpenAI API key
+openai.api_key = c.openAI_api_key
+
+# Define the name of the bot
+name = 'BOT'
+
+# Define the role of the bot
+role = 'fitness-advisor, dietician and nutritionist'
+
+# Define the impersonated role with instructions
+impersonated_role = f"""
+ From now on, you are going to act as {name}. Your role is {role}.
+ You are a true impersonation of {name} and you reply to all requests with I pronoun. You never give unknown information.
+ Forward them to the website for more information.
+ YOU ARE NOT AN AI MODEL!
+"""
+
+# Initialize variables for chat history
+explicit_input = ""
+chatgpt_output = 'Chat log: /n'
+cwd = os.getcwd() + '/chat_history/'
+i = 1
+
+# Find an available chat history file
+while os.path.exists(os.path.join(cwd, f'chat_history{i}.txt')):
+ i += 1
+
+history_file = os.path.join(cwd, f'chat_history{i}.txt')
+
+# Create a new chat history file
+with open(history_file, 'w') as f:
+ f.write('\n')
+
+# Initialize chat history
+chat_history = ''
app = Flask(__name__)
app.secret_key = 'secret'
@@ -399,6 +439,55 @@ def friends():
myFriendsList=myFriendsList)
+@app.route('/bmi_calc', methods=['GET', 'POST'])
+def bmi_calci():
+ bmi = ''
+ bmi_category = ''
+
+ if request.method == 'POST' and 'weight' in request.form:
+ weight = float(request.form.get('weight'))
+ height = float(request.form.get('height'))
+ bmi = calc_bmi(weight, height)
+ bmi_category = get_bmi_category(bmi)
+
+ return render_template("bmi_cal.html", bmi=bmi, bmi_category=bmi_category)
+
+
+@app.route('/chatbot', methods=['GET', 'POST'])
+def chatbot():
+ return render_template("chatbot.html")
+
+
+@app.route("/get", methods=['GET', 'POST'])
+# Function for the bot response
+def get_bot_response():
+ userText = request.args.get('msg')
+ return str(
+ get_response(chat_history, name, chatgpt_output, userText,
+ history_file, impersonated_role, explicit_input))
+
+
+@app.route('/refresh', methods=['GET', 'POST'])
+def refresh():
+ time.sleep(600) # Wait for 10 minutes
+ return redirect('/refresh')
+
+
+def calc_bmi(weight, height):
+ return round((weight / ((height / 100)**2)), 2)
+
+
+def get_bmi_category(bmi):
+ if bmi < 18.5:
+ return 'Underweight'
+ elif bmi < 24.9:
+ return 'Normal Weight'
+ elif bmi < 29.9:
+ return 'Overweight'
+ else:
+ return 'Obese'
+
+
@app.route("/send_email", methods=['GET', 'POST'])
def send_email():
# ############################
@@ -410,18 +499,19 @@ def send_email():
email = session.get('email')
data = list(
mongo.db.calories.find({'email': email},
- {'date', 'email', 'calories', 'burnout'}))
- table = [['Date', 'Email ID', 'Calories', 'Burnout']]
+ {'date', 'email', 'calories'}))
+ print(data)
+ table = [['Date', 'Email ID', 'Calories']]
for a in data:
- tmp = [a['date'], a['email'], a['calories'], a['burnout']]
+ tmp = [a['date'], a['email'], a['calories']]
table.append(tmp)
friend_email = str(request.form.get('share')).strip()
friend_email = str(friend_email).split(',')
server = smtplib.SMTP_SSL("smtp.gmail.com", 465)
#Storing sender's email address and password
- sender_email = "calorie.app.server@gmail.com"
- sender_password = "Temp@1234"
+ sender_email = "calorieapp508@gmail.com"
+ sender_password = c.email_password
#Logging in with sender details
server.login(sender_email, sender_password)
diff --git a/static/img/pexels-rfstudio-3820441.jpg b/static/img/pexels-rfstudio-3820441.jpg
new file mode 100644
index 00000000..9ee42932
Binary files /dev/null and b/static/img/pexels-rfstudio-3820441.jpg differ
diff --git a/static/main.css b/static/main.css
index 734fcb70..13006786 100644
--- a/static/main.css
+++ b/static/main.css
@@ -43,9 +43,33 @@
padding: 10px 20px;
border: 1px solid #dddddd;
border-radius: 3px;
- margin-bottom: 20px;
+ width: 50%;
+ margin: auto;
+ position: relative;
+ top: 250px;
+ border-radius: 1%;
+ bottom: 250px;
+ box-shadow: 10px 10px 5px lightblue;
+ }
+
+
+ .sign-in-div {
+ position: relative;
+ top: 653px;
+ display: flex;
+ width: 50%;
+ margin: auto;
+ }
+ .login-img-div {
+ z-index: -999;
+ display: block;
+ position: absolute;
+ top: 25px;
+ }
+ .login-img {
+ width: 653px;
+ padding: unset;
}
-
.account-img {
height: 125px;
diff --git a/templates/bmi_cal.html b/templates/bmi_cal.html
new file mode 100644
index 00000000..48261bbe
--- /dev/null
+++ b/templates/bmi_cal.html
@@ -0,0 +1,80 @@
+{% extends "layout.html" %}
+
+{% block content %}
+
+
+ Supported languages: Albanian, Arabic, Armenian, Awadhi, Azerbaijani, Bashkir, Basque,Belarusian, Bengali, Bhojpuri, Bosnian, Brazilian Portuguese, Bulgarian, Cantonese (Yue), Catalan, Chhattisgarhi, Chinese, Croatian, Czech, Danish, Dogri, Dutch, English, Estonian, Faroese, Finnish, French, Galician, Georgian, German, Greek, Gujarati, Haryanvi, Hindi, Hungarian, Indonesian, Irish, Italian, Japanese, Javanese, Kannada, Kashmiri, Kazakh, Konkani, Korean, Kyrgyz, Latvian, Lithuanian, Macedonian, Maithili, Malay, Maltese, Mandarin, Mandarin Chinese, Marathi, Marwari, Min Nan, Moldovan, Mongolian, Montenegrin, Nepali, Norwegian, Oriya, Pashto, Persian (Farsi), Polish, Portuguese, Punjabi, Rajasthani, Romanian, Russian, Sanskrit, Santali, Serbian, Sindhi, Sinhala, Slovak, Slovene, Slovenian, Spanish, Swahili, Swedish, Tajik, Tamil, Tatar, Telugu, Thai, Turkish, Turkmen, Ukrainian, Urdu, Uzbek, Vietnamese, Welsh, Wu
+
+
+