saiganesh2004 commited on
Commit
2b11126
Β·
verified Β·
1 Parent(s): ae7ad2e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +143 -0
app.py CHANGED
@@ -0,0 +1,143 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from datetime import datetime
3
+
4
+ st.set_page_config(
5
+ page_title="FIT Plan AI - Milestone 1",
6
+ page_icon="πŸ’ͺ",
7
+ layout="centered"
8
+ )
9
+
10
+ st.title("πŸ’ͺ FIT Plan AI – Personalized Fitness Profile")
11
+ st.markdown("---")
12
+
13
+ if "form_submitted" not in st.session_state:
14
+ st.session_state.form_submitted = False
15
+
16
+ with st.form("fitness_profile_form"):
17
+ st.header("πŸ“‹ Your Fitness Profile")
18
+ st.subheader("πŸ‘€ Personal Information")
19
+
20
+ col1, col2 = st.columns(2)
21
+
22
+ with col1:
23
+ name = st.text_input("Full Name *")
24
+ height = st.number_input("Height (cm) *", min_value=1.0, max_value=300.0, value=170.0)
25
+
26
+ with col2:
27
+ age = st.number_input("Age", min_value=10, max_value=120, value=25)
28
+ weight = st.number_input("Weight (kg) *", min_value=1.0, max_value=500.0, value=70.0)
29
+
30
+ gender = st.selectbox("Gender", ["Male", "Female", "Other"])
31
+
32
+ st.subheader("🎯 Fitness Details")
33
+
34
+ goal = st.selectbox(
35
+ "Fitness Goal *",
36
+ ["Weight Loss", "Build Muscle", "Strength Gain", "Abs Building", "Flexibility"]
37
+ )
38
+
39
+ equipment = st.multiselect(
40
+ "Available Equipment *",
41
+ [
42
+ "Dumbbells",
43
+ "Resistance Bands",
44
+ "Barbell",
45
+ "Pull-up Bar",
46
+ "Treadmill",
47
+ "Kettlebells",
48
+ "Jump Rope",
49
+ "Yoga Mat",
50
+ "No Equipment (Bodyweight only)"
51
+ ],
52
+ default=["No Equipment (Bodyweight only)"]
53
+ )
54
+
55
+ fitness_level = st.select_slider(
56
+ "Fitness Level *",
57
+ options=["Beginner", "Intermediate", "Advanced"],
58
+ value="Beginner"
59
+ )
60
+
61
+ st.markdown("---")
62
+ submit = st.form_submit_button("Submit Profile", use_container_width=True)
63
+
64
+ def bmi_category(bmi):
65
+ if bmi < 18.5:
66
+ return "Underweight"
67
+ elif bmi < 25:
68
+ return "Normal"
69
+ elif bmi < 30:
70
+ return "Overweight"
71
+ else:
72
+ return "Obese"
73
+
74
+ if submit:
75
+ if not name:
76
+ st.error("Please enter your name.")
77
+ st.stop()
78
+
79
+ if not equipment:
80
+ st.error("Please select at least one equipment option.")
81
+ st.stop()
82
+
83
+ height_m = height / 100
84
+ bmi = round(weight / (height_m ** 2), 2)
85
+ bmi_status = bmi_category(bmi)
86
+
87
+ st.success("βœ… Profile Submitted Successfully!")
88
+
89
+ st.session_state.update({
90
+ "form_submitted": True,
91
+ "name": name,
92
+ "bmi": bmi,
93
+ "bmi_status": bmi_status,
94
+ "age": age,
95
+ "goal": goal,
96
+ "equipment": equipment,
97
+ "fitness_level": fitness_level,
98
+ "height": height,
99
+ "weight": weight,
100
+ "gender": gender
101
+ })
102
+
103
+ if st.session_state.form_submitted:
104
+ st.markdown("---")
105
+ st.success(f"Welcome, **{st.session_state.name}**!")
106
+
107
+ col1, col2, col3 = st.columns(3)
108
+ col1.metric("πŸ“Š BMI", st.session_state.bmi)
109
+ col2.metric("🏷 Category", st.session_state.bmi_status)
110
+ col3.metric("πŸ‹οΈ Level", st.session_state.fitness_level)
111
+
112
+ st.markdown("---")
113
+
114
+ report_text = f"""
115
+ FIT PLAN AI - PROFILE REPORT
116
+ Generated on: {datetime.now().strftime("%Y-%m-%d %H:%M:%S")}
117
+
118
+ Name: {st.session_state.name}
119
+ Age: {st.session_state.age}
120
+ Gender: {st.session_state.gender}
121
+ Height: {st.session_state.height} cm
122
+ Weight: {st.session_state.weight} kg
123
+
124
+ BMI: {st.session_state.bmi}
125
+ Category: {st.session_state.bmi_status}
126
+
127
+ Goal: {st.session_state.goal}
128
+ Level: {st.session_state.fitness_level}
129
+ Equipment: {', '.join(st.session_state.equipment)}
130
+
131
+ Stay consistent and trust the process!
132
+ """
133
+
134
+ st.download_button(
135
+ "πŸ“₯ Download Profile Report",
136
+ data=report_text,
137
+ file_name=f"FITPlanAI_{st.session_state.name}_Profile.txt",
138
+ mime="text/plain",
139
+ use_container_width=True
140
+ )
141
+
142
+ st.markdown("---")
143
+ st.caption("FIT Plan AI - Milestone 1 | BMI Calculator")