Update app.py
Browse files
app.py
CHANGED
@@ -17,17 +17,17 @@ def bmi(name, height, weight, feeling):
|
|
17 |
output_str = f"Hello π {name}...\nYour BMI is {bmi_value:.2f}"
|
18 |
feeling_msg = "You're feeling happy today! π" if feeling == "Yes" else "Hope you feel better soon! π"
|
19 |
|
20 |
-
# Append new entry
|
21 |
-
new_entry = {
|
22 |
"Name": name,
|
23 |
"Height": height,
|
24 |
"Weight": weight,
|
25 |
"BMI": round(bmi_value, 2),
|
26 |
"Feeling": feeling
|
27 |
-
}
|
28 |
|
29 |
global df_history
|
30 |
-
df_history =
|
31 |
df_history.to_csv(DATA_FILE, index=False)
|
32 |
|
33 |
return output_str, result_emoticon, feeling_msg, df_history
|
@@ -51,8 +51,7 @@ interface = gr.Interface(
|
|
51 |
["guro", 1.75, 70, "Yes"],
|
52 |
["levan", 1.69, 73, "Yes"]
|
53 |
],
|
54 |
-
|
55 |
-
theme = gr.themes.Soft(),
|
56 |
title="BMI Calculator with Emotions π",
|
57 |
description="Your BMI is calculated and saved with your name and mood. Try an example or input your own info!"
|
58 |
)
|
|
|
17 |
output_str = f"Hello π {name}...\nYour BMI is {bmi_value:.2f}"
|
18 |
feeling_msg = "You're feeling happy today! π" if feeling == "Yes" else "Hope you feel better soon! π"
|
19 |
|
20 |
+
# Append new entry using concat (instead of deprecated _append)
|
21 |
+
new_entry = pd.DataFrame([{
|
22 |
"Name": name,
|
23 |
"Height": height,
|
24 |
"Weight": weight,
|
25 |
"BMI": round(bmi_value, 2),
|
26 |
"Feeling": feeling
|
27 |
+
}])
|
28 |
|
29 |
global df_history
|
30 |
+
df_history = pd.concat([df_history, new_entry], ignore_index=True)
|
31 |
df_history.to_csv(DATA_FILE, index=False)
|
32 |
|
33 |
return output_str, result_emoticon, feeling_msg, df_history
|
|
|
51 |
["guro", 1.75, 70, "Yes"],
|
52 |
["levan", 1.69, 73, "Yes"]
|
53 |
],
|
54 |
+
theme=gr.themes.Soft(),
|
|
|
55 |
title="BMI Calculator with Emotions π",
|
56 |
description="Your BMI is calculated and saved with your name and mood. Try an example or input your own info!"
|
57 |
)
|