Harry2406 commited on
Commit
e62a4c7
·
verified ·
1 Parent(s): 6cc60a4

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +73 -36
src/streamlit_app.py CHANGED
@@ -1,53 +1,90 @@
1
  import streamlit as st
2
 
3
- # Page config
4
  st.set_page_config(page_title="Fitness Profile", page_icon="🏋️", layout="centered")
5
 
6
- # Title
7
- st.markdown("## 🏋️ Your Fitness Profile")
8
 
9
  st.markdown("---")
10
 
11
- # Fitness Goal
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  fitness_goal = st.selectbox(
13
  "Fitness Goal",
14
- ["Build Muscle", "Lose Weight", "Improve Endurance", "General Fitness"]
15
  )
16
 
17
- # Available Equipment
18
- st.write("Available Equipment")
19
- col1, col2 = st.columns(2)
20
-
21
- with col1:
22
- dumbbells = st.checkbox("Dumbbells")
23
- no_equipment = st.checkbox("No Equipment")
24
-
25
- with col2:
26
- resistance_bands = st.checkbox("Resistance Bands")
27
 
28
- # Fitness Level
29
- st.write("Fitness Level")
30
  fitness_level = st.radio(
31
- "",
32
  ["Beginner", "Intermediate", "Advanced"],
33
  horizontal=True
34
  )
35
 
36
- st.markdown("")
37
-
38
- # Generate Button
39
- if st.button("Generate Personalized Plan", use_container_width=True):
40
- st.success("Generating your personalized workout plan...")
41
-
42
- st.write("### Your Selected Preferences:")
43
- st.write("**Goal:**", fitness_goal)
44
- st.write("**Equipment:**",
45
- ", ".join(
46
- [item for item, selected in {
47
- "Dumbbells": dumbbells,
48
- "Resistance Bands": resistance_bands,
49
- "No Equipment": no_equipment
50
- }.items() if selected]
51
- ) or "None Selected"
52
- )
53
- st.write("**Fitness Level:**", fitness_level)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import streamlit as st
2
 
 
3
  st.set_page_config(page_title="Fitness Profile", page_icon="🏋️", layout="centered")
4
 
5
+ st.title("🏋️ Personalized Fitness Profile")
 
6
 
7
  st.markdown("---")
8
 
9
+ # =========================
10
+ # 1️⃣ Personal Information
11
+ # =========================
12
+ st.header("1. Personal Information")
13
+
14
+ name = st.text_input("Name *")
15
+
16
+ height_cm = st.number_input("Height (in centimeters) *", min_value=0.0, format="%.2f")
17
+ weight_kg = st.number_input("Weight (in kilograms) *", min_value=0.0, format="%.2f")
18
+
19
+ # =========================
20
+ # 2️⃣ Fitness Details
21
+ # =========================
22
+ st.header("2. Fitness Details")
23
+
24
  fitness_goal = st.selectbox(
25
  "Fitness Goal",
26
+ ["Build Muscle", "Weight Loss", "Strength Gain", "Abs Building", "Flexible"]
27
  )
28
 
29
+ equipment = st.multiselect(
30
+ "Available Equipment (Multiple selection allowed)",
31
+ ["Dumbbells", "Resistance Band", "Yoga Mat", "No Equipment"]
32
+ )
 
 
 
 
 
 
33
 
 
 
34
  fitness_level = st.radio(
35
+ "Fitness Level",
36
  ["Beginner", "Intermediate", "Advanced"],
37
  horizontal=True
38
  )
39
 
40
+ st.markdown("---")
41
+
42
+ # =========================
43
+ # 3️⃣ Submit Button
44
+ # =========================
45
+ if st.button("Generate Profile"):
46
+
47
+ # =========================
48
+ # Validation
49
+ # =========================
50
+ if name.strip() == "":
51
+ st.error(" Name is required.")
52
+ elif height_cm <= 0:
53
+ st.error(" Height must be greater than zero.")
54
+ elif weight_kg <= 0:
55
+ st.error("❌ Weight must be greater than zero.")
56
+ else:
57
+ # =========================
58
+ # BMI Calculation
59
+ # =========================
60
+ height_m = height_cm / 100 # Convert cm to meters
61
+ bmi = weight_kg / (height_m ** 2)
62
+ bmi = round(bmi, 2)
63
+
64
+ # =========================
65
+ # BMI Category
66
+ # =========================
67
+ if bmi < 18.5:
68
+ category = "Underweight"
69
+ elif 18.5 <= bmi < 24.9:
70
+ category = "Normal"
71
+ elif 25 <= bmi < 29.9:
72
+ category = "Overweight"
73
+ else:
74
+ category = "Obese"
75
+
76
+ # =========================
77
+ # Display Results
78
+ # =========================
79
+ st.success("✅ Profile Generated Successfully!")
80
+
81
+ st.subheader(f"👤 {name}'s Fitness Summary")
82
+
83
+ st.write(f"**Height (m):** {round(height_m, 2)} m")
84
+ st.write(f"**Weight (kg):** {weight_kg} kg")
85
+ st.write(f"**BMI:** {bmi}")
86
+ st.write(f"**BMI Category:** {category}")
87
+ st.write(f"**Fitness Goal:** {fitness_goal}")
88
+ st.write(f"**Fitness Level:** {fitness_level}")
89
+ st.write(f"**Available Equipment:** {', '.join(equipment) if equipment else 'None Selected'}")
90
+