Module_2 / src /streamlit_app.py
Springboardmen's picture
Update src/streamlit_app.py
2cf4a4b verified
raw
history blame
3.2 kB
import streamlit as st
# ---------------------------------------------------
# PAGE CONFIG
# ---------------------------------------------------
st.set_page_config(page_title="FitPlan AI", layout="wide")
st.title(" FitPlan AI – User Fitness Profile")
# ---------------------------------------------------
# PERSONAL INFORMATION
# ---------------------------------------------------
st.subheader("πŸ‘€ Personal Information")
name = st.text_input("Enter Your Name")
gender = st.selectbox(
"Gender",
["Male", "Female", "Other"]
)
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 (Basic Logic Only)
# ---------------------------------------------------
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
# ---------------------------------------------------
st.subheader("Available Equipment")
col1, col2 = st.columns(2)
with col1:
dumbbells = st.checkbox("Dumbbells")
resistance_band = st.checkbox("Resistance Band")
yoga_mat = st.checkbox("Yoga Mat")
no_equipment = st.checkbox("No Equipment")
with col2:
treadmill = st.checkbox("Treadmill")
cycle = st.checkbox("Cycle")
pullups_bar = st.checkbox("Pullups Bar")
weight_plates = st.checkbox("Weight Plates")
equipment = []
equipment_map = {
"Dumbbells": dumbbells,
"Resistance Band": resistance_band,
"Yoga Mat": yoga_mat,
"No Equipment": no_equipment,
"Treadmill": treadmill,
"Cycle": cycle,
"Pullups Bar": pullups_bar,
"Weight Plates": weight_plates,
}
for item, selected in equipment_map.items():
if selected:
equipment.append(item)
# ---------------------------------------------------
# FITNESS LEVEL
# ---------------------------------------------------
st.subheader("πŸ“ˆ Fitness Level")
fitness_level = st.radio(
"",
["Beginner", "Intermediate", "Advanced"],
horizontal=True
)
# ---------------------------------------------------
# SUBMIT BUTTON (Backend Receiving Data)
# ---------------------------------------------------
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
})