Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -65,25 +65,38 @@ def get_health_articles(query):
|
|
65 |
|
66 |
# Streamlit app layout
|
67 |
def main():
|
68 |
-
|
69 |
-
st.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
|
71 |
# File upload
|
72 |
uploaded_file = st.file_uploader("Upload your dataset (CSV)", type=["csv"])
|
73 |
if uploaded_file:
|
74 |
df = load_data(uploaded_file)
|
75 |
-
st.write("Dataset
|
76 |
st.dataframe(df.head())
|
77 |
|
78 |
# User input for analysis
|
79 |
-
st.
|
80 |
-
gender = st.selectbox("Gender", ["Male", "Female"])
|
81 |
-
age = st.slider("Age", 18, 35, step=1)
|
82 |
-
depression = st.slider("Depression Level (1-10)", 1, 10)
|
83 |
-
anxiety = st.slider("Anxiety Level (1-10)", 1, 10)
|
84 |
-
isolation = st.slider("Isolation Level (1-10)", 1, 10)
|
85 |
-
future_insecurity = st.slider("Future Insecurity Level (1-10)", 1, 10)
|
86 |
-
stress_relief_activities = st.slider("Stress Relief Activities Level (1-10)", 1, 10)
|
87 |
|
88 |
# Data dictionary for advice
|
89 |
user_data = {
|
@@ -97,19 +110,22 @@ def main():
|
|
97 |
}
|
98 |
|
99 |
# Provide advice based on user inputs
|
100 |
-
if st.button("Get Observed Advice"):
|
101 |
-
st.subheader("Health Advice Based on Observations")
|
102 |
advice = provide_observed_advice(user_data)
|
103 |
-
|
104 |
-
|
|
|
|
|
|
|
105 |
|
106 |
# Fetch related health articles based on user input
|
107 |
-
st.subheader("Related Health Articles")
|
108 |
query = "mental health anxiety depression isolation stress relief"
|
109 |
articles = get_health_articles(query)
|
110 |
if articles:
|
111 |
for article in articles:
|
112 |
-
st.write(f"
|
113 |
else:
|
114 |
st.write("No articles found. Please check your API key or internet connection.")
|
115 |
|
|
|
65 |
|
66 |
# Streamlit app layout
|
67 |
def main():
|
68 |
+
# Set a background color
|
69 |
+
st.markdown(
|
70 |
+
"""
|
71 |
+
<style>
|
72 |
+
.stApp {
|
73 |
+
background-color: #F4F4F9;
|
74 |
+
}
|
75 |
+
</style>
|
76 |
+
""",
|
77 |
+
unsafe_allow_html=True
|
78 |
+
)
|
79 |
+
|
80 |
+
# Title and header
|
81 |
+
st.title("π **Student Health Advisory Assistant** π")
|
82 |
+
st.markdown("### **Analyze your well-being and get personalized advice**")
|
83 |
|
84 |
# File upload
|
85 |
uploaded_file = st.file_uploader("Upload your dataset (CSV)", type=["csv"])
|
86 |
if uploaded_file:
|
87 |
df = load_data(uploaded_file)
|
88 |
+
st.write("### Dataset Preview:")
|
89 |
st.dataframe(df.head())
|
90 |
|
91 |
# User input for analysis
|
92 |
+
st.markdown("### **Input Your Details**")
|
93 |
+
gender = st.selectbox("πΉ Gender", ["Male", "Female"], help="Select your gender.")
|
94 |
+
age = st.slider("πΉ Age", 18, 35, step=1)
|
95 |
+
depression = st.slider("πΉ Depression Level (1-10)", 1, 10)
|
96 |
+
anxiety = st.slider("πΉ Anxiety Level (1-10)", 1, 10)
|
97 |
+
isolation = st.slider("πΉ Isolation Level (1-10)", 1, 10)
|
98 |
+
future_insecurity = st.slider("πΉ Future Insecurity Level (1-10)", 1, 10)
|
99 |
+
stress_relief_activities = st.slider("πΉ Stress Relief Activities Level (1-10)", 1, 10)
|
100 |
|
101 |
# Data dictionary for advice
|
102 |
user_data = {
|
|
|
110 |
}
|
111 |
|
112 |
# Provide advice based on user inputs
|
113 |
+
if st.button("π Get Observed Advice", key="advice_btn"):
|
114 |
+
st.subheader("π **Health Advice Based on Observations** π")
|
115 |
advice = provide_observed_advice(user_data)
|
116 |
+
if advice:
|
117 |
+
for i, tip in enumerate(advice, 1):
|
118 |
+
st.write(f"π {i}. {tip}")
|
119 |
+
else:
|
120 |
+
st.warning("No advice available based on your inputs.")
|
121 |
|
122 |
# Fetch related health articles based on user input
|
123 |
+
st.subheader("π° **Related Health Articles** π°")
|
124 |
query = "mental health anxiety depression isolation stress relief"
|
125 |
articles = get_health_articles(query)
|
126 |
if articles:
|
127 |
for article in articles:
|
128 |
+
st.write(f"π [{article['title']}]({article['url']})")
|
129 |
else:
|
130 |
st.write("No articles found. Please check your API key or internet connection.")
|
131 |
|