Module_2 / src /streamlit_app.py
Springboardmen's picture
Update src/streamlit_app.py
8e4ec5e verified
raw
history blame
4.78 kB
import streamlit as st
# ---------------------------------------------------
# PAGE CONFIG
# ---------------------------------------------------
st.set_page_config(page_title="FitPlan AI", layout="centered")
st.title(" FitPlan AI – User Fitness Profile")
# ---------------------------------------------------
# PERSONAL INFORMATION
# ---------------------------------------------------
st.subheader("πŸ‘€ Personal Information")
name = st.text_input("Enter Your Name")
st.subheader("Gender")
gender = st.radio(
"",
["Male", "Female"],
horizontal=True,index=0
)
col1, col2 = st.columns(2)
with col1:
height = st.number_input("Height (in cm)", min_value=100, max_value=250)
with col2:
weight = st.number_input("Weight (in kg)", min_value=30, max_value=200)
# ---------------------------------------------------
# BMI CALCULATION
# ---------------------------------------------------
bmi = None
if height > 0 and weight > 0:
height_m = height / 100
bmi = weight / (height_m ** 2)
st.write(f"### πŸ“Š Your BMI: {bmi:.2f}")
# ---------------------------------------------------
# FITNESS GOAL
# ---------------------------------------------------
st.subheader("🎯 Fitness Goal")
goal = st.selectbox(
"",
[
"Flexible",
"Weight Loss",
"Build Muscle",
"Strength Gaining",
"Abs Building"
]
)
# ---------------------------------------------------
# EQUIPMENT (FULL IMPLEMENTATION)
# ---------------------------------------------------
st.subheader("πŸ‹οΈ Available Equipment")
equipment_map = {}
# 🏠 Bodyweight
equipment_map["No Equipment"] = st.checkbox("No Equipment")
equipment_map["Pull-up Bar"] = st.checkbox("Pull-up Bar")
equipment_map["Dip Bars"] = st.checkbox("Dip Bars")
equipment_map["Push-up Handles"] = st.checkbox("Push-up Handles")
# πŸ‹οΈ Free Weights
equipment_map["Dumbbells"] = st.checkbox("Dumbbells")
equipment_map["Adjustable Dumbbells"] = st.checkbox("Adjustable Dumbbells")
equipment_map["Barbell"] = st.checkbox("Barbell")
equipment_map["Weight Plates"] = st.checkbox("Weight Plates")
equipment_map["Kettlebells"] = st.checkbox("Kettlebells")
equipment_map["Medicine Ball"] = st.checkbox("Medicine Ball")
# 🧘 Flexibility & Core
equipment_map["Yoga Mat"] = st.checkbox("Yoga Mat")
equipment_map["Resistance Band"] = st.checkbox("Resistance Band")
equipment_map["Bosu Ball"] = st.checkbox("Bosu Ball")
equipment_map["Stability Ball"] = st.checkbox("Stability Ball")
equipment_map["Foam Roller"] = st.checkbox("Foam Roller")
equipment_map["Hula Hoop Ring"] = st.checkbox("Hula Hoop Ring")
# πŸƒ Cardio Equipment
equipment_map["Treadmill"] = st.checkbox("Treadmill")
equipment_map["Exercise Bike"] = st.checkbox("Exercise Bike")
equipment_map["Skipping Rope"] = st.checkbox("Skipping Rope")
equipment_map["Rowing Machine"] = st.checkbox("Rowing Machine")
equipment_map["Elliptical Trainer"] = st.checkbox("Elliptical Trainer")
equipment_map["Stair Climber"] = st.checkbox("Stair Climber")
# πŸ’ͺ Strength Machines
equipment_map["Incline Bench"] = st.checkbox("Incline Bench")
equipment_map["Flat Bench"] = st.checkbox("Flat Bench")
equipment_map["Smith Machine"] = st.checkbox("Smith Machine")
equipment_map["Leg Press Machine"] = st.checkbox("Leg Press Machine")
equipment_map["Cable Machine"] = st.checkbox("Cable Machine")
equipment_map["Lat Pulldown Machine"] = st.checkbox("Lat Pulldown Machine")
equipment_map["Chest Press Machine"] = st.checkbox("Chest Press Machine")
# βœ‹ Small Tools
equipment_map["Hand Gripper"] = st.checkbox("Hand Gripper")
equipment_map["Wrist Roller"] = st.checkbox("Wrist Roller")
equipment_map["Ankle Weights"] = st.checkbox("Ankle Weights")
equipment_map["Resistance Tubes"] = st.checkbox("Resistance Tubes")
# Convert selected equipment to list
equipment = [item for item, selected in equipment_map.items() if selected]
# ---------------------------------------------------
# FITNESS LEVEL
# ---------------------------------------------------
st.subheader("πŸ“ˆ Fitness Level")
fitness_level = st.radio(
"",
["Beginner", "Intermediate", "Advanced"],
horizontal=True
)
# ---------------------------------------------------
# SUBMIT BUTTON
# ---------------------------------------------------
if st.button("Submit Profile"):
if not name:
st.error("Please enter your name.")
elif not equipment:
st.error("Please select at least one equipment option.")
else:
st.success("βœ… Profile Submitted Successfully!")
st.json({
"Name": name,
"Gender": gender,
"BMI": round(bmi, 2) if bmi else None,
"Goal": goal,
"Fitness Level": fitness_level,
"Equipment": equipment
})