Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance Image Display with API Integration #63 #89

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
.env
98 changes: 35 additions & 63 deletions app.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import base64
import datetime
import time
from pymongo import MongoClient

import streamlit as st
import plotly.express as px
import pandas as pd
Expand All @@ -12,33 +10,6 @@
from dotenv import load_dotenv
#AI Integration
import anthropic
import datetime
# CSS for Scroll to Top Button
scroll_to_top = """
<style>
#scrollButton {
position: fixed;
bottom: 20px;
right: 20px;
z-index: 99;
font-size: 18px;
border: none;
outline: none;
background-color: rgb(4, 170, 109);
color: white;
cursor: pointer;
padding: 10px;
border-radius: 10px;
opacity: 0.7;
}

#scrollButton:hover {
background-color: rgb(4, 170, 109);
opacity: 1;
}
</style>
"""



#Changes made by --Charvi Arora
Expand Down Expand Up @@ -70,15 +41,8 @@ def anxiety_management_guide(mood, feeling_description, current_stress_level, re
]
)


# Set page config (must be the first Streamlit command)
st.set_page_config(page_title="SereniFi", page_icon=":relieved:", layout="centered")
st.markdown(scroll_to_top, unsafe_allow_html=True)
def scroll_to_top_button():
st.markdown('<a id="scrollButton" title="Go to top" href="#top">↑ Top</a>', unsafe_allow_html=True)
st.markdown('<div id="top"></div>', unsafe_allow_html=True)

scroll_to_top_button()
st.set_page_config(page_title="Anxiety Relief App", page_icon=":relieved:", layout="centered")

# Data for mental health (sampled)
data = {
Expand Down Expand Up @@ -168,7 +132,7 @@ def main():
"background-color": "rgba(0, 0, 0, 0.8)", # More opaque background
"transition": "background-color 0.3s ease, transform 0.2s"
},
"nav-link-selected": {"background-color": "#04AA6D", "color": "#fff","font-size": "14px",}
"nav-link-selected": {"background-color": "#04AA6D", "color": "#fff", "transform": "scale(1.1)"}
}
)

Expand Down Expand Up @@ -198,7 +162,33 @@ def show_main_page():



st.image("https://images.pexels.com/photos/185801/pexels-photo-185801.jpeg?auto=compress&cs=tinysrgb&w=600", caption="Breathe and Relax", use_column_width=True)
#st.image("https://images.pexels.com/photos/185801/pexels-photo-185801.jpeg?auto=compress&cs=tinysrgb&w=600", caption="Breathe and Relax", use_column_width=True)
# dynamic images
# Add this in the show_main_page function
def fetch_dynamic_images(query):
API_KEY = os.getenv("UNSPLASH_API_KEY") # Ensure you have your Unsplash API key in the .env file
response = requests.get(f"https://api.unsplash.com/photos/random?query={query}&client_id={API_KEY}")

if response.status_code == 200:
image = response.json() # This will be a single image object
return [image['urls']['small']] # Return a list containing the small size URL
else:
st.error("Error fetching images from Unsplash.")
return []
def imgContainer(query):
images = fetch_dynamic_images(query)
if images:
# Create a div container for images
image_container = st.container()
with image_container:
st.markdown(f'<div class="img-container" style="width: inherit;">', unsafe_allow_html=True)
for img_url in images:
st.markdown(f'<img src="{img_url}" style="width: 100%;border: 2px solid;border-color: black;border-radius: 10px;">', unsafe_allow_html=True)
st.markdown('</div>', unsafe_allow_html=True)


st.subheader("Dynamic Anxiety Relief Images")
imgContainer("Peace") # You can customize the query based on user input or context

st.write("---")

Expand Down Expand Up @@ -376,7 +366,7 @@ def show_main_page():
st.plotly_chart(fig_selected)

st.write("---")
st.markdown('<p style="text-align: center;">© 2024 SereniFi. All rights reserved.</p>', unsafe_allow_html=True)
st.markdown('<p style="text-align: center;">© 2024 Anxiety Relief Platform. All rights reserved.</p>', unsafe_allow_html=True)

def soothing_sounds():
st.header("🎵 Calm Down with Soothing Sounds")
Expand Down Expand Up @@ -458,25 +448,7 @@ def show_calm_space():

if selected_challenge:
st.write(f"**Today's Challenge:** {challenges[selected_challenge]}")
st.write("Remember, consistency is key to building habits and improving your mental well-being.")

#Progress Bar Feature added by suhaib-lone
if st.button("Start Progress"):
progress_bar=st.progress(0)
if selected_challenge == "Meditation" or selected_challenge == "journaling":
challenge_time=600
elif selected_challenge == "Yoga":
challenge_time=900
elif selected_challenge == "Breathing":
challenge_time=300
else:
challenge_time=1200
for i in range(challenge_time):
time.sleep(1)
progress_bar.progress((i+1)/challenge_time)
st.success("Ding! Ding! Time UP!")


st.write("Set a reminder to complete this challenge today. Remember, consistency is key to building habits and improving your mental well-being.")

st.write("---")

Expand Down Expand Up @@ -513,7 +485,7 @@ def show_calm_space():


st.write("---")
st.markdown('<p style="text-align: center;">© 2024 SereniFi. All rights reserved.</p>', unsafe_allow_html=True)
st.markdown('<p style="text-align: center;">© 2024 Anxiety Relief Platform. All rights reserved.</p>', unsafe_allow_html=True)



Expand All @@ -522,7 +494,7 @@ def show_about_and_feedback():
st.title("About Us & Feedback")

st.write("""
**Welcome to SereniFi!**
**Welcome to Our Anxiety Relief Platform!**

We are dedicated to promoting mental wellness through interactive and accessible tools. Our mission is to provide a supportive environment where individuals can explore effective techniques for managing anxiety and improving overall mental well-being.
""")
Expand Down Expand Up @@ -590,7 +562,7 @@ def show_about_and_feedback():


st.write("---")
st.markdown('<p style="text-align: center;">© 2024 SereniFi. All rights reserved.</p>', unsafe_allow_html=True)
st.markdown('<p style="text-align: center;">© 2024 Anxiety Relief Platform. All rights reserved.</p>', unsafe_allow_html=True)



Expand Down