Spaces:
Running
Running
import streamlit as st | |
from PIL import Image | |
import os | |
# App title and description | |
st.set_page_config(page_title="Tarun-Shrishti wedding", page_icon="❤️", layout="centered") | |
st.title("🌟 #TASH") | |
st.write("Upload your images below (You can upload any number of times!)") | |
# Upload directory | |
UPLOAD_DIR = "uploaded_images" | |
os.makedirs(UPLOAD_DIR, exist_ok=True) | |
# Sidebar for navigation and instructions | |
with st.sidebar: | |
st.header("How to Use") | |
st.write("1. Click 'Browse files' to select images.") | |
st.write("2. Upload multiple images at once.") | |
st.write("3. View your uploaded images in the main area.") | |
st.write("Supported formats: JPG, PNG, GIF.") | |
# # Increase file upload size limit | |
# st.set_option("server.maxUploadSize", 1024) | |
# File uploader | |
uploaded_files = st.file_uploader( | |
"Choose image files", type=["jpg", "jpeg", "png", "gif"], accept_multiple_files=True | |
) | |
if uploaded_files: | |
st.success(f"You have uploaded {len(uploaded_files)} image(s).") | |
# Display uploaded images | |
st.subheader("Uploaded Images") | |
cols = st.columns(3) | |
for index, uploaded_file in enumerate(uploaded_files): | |
# Save uploaded file | |
file_path = os.path.join(UPLOAD_DIR, uploaded_file.name) | |
with open(file_path, "wb") as f: | |
f.write(uploaded_file.getbuffer()) | |
# Display image | |
img = Image.open(file_path) | |
with cols[index % 3]: | |
st.image(img, caption=uploaded_file.name, width=200) | |
# Blank lines between image upload and text message | |
st.write("\n") | |
st.write("\n") | |
st.write("\n") | |
st.write("\n") | |
# Congratulation message input | |
st.subheader("Leave a Congratulation Message if you want ❤️ ") | |
message = st.text_area("Write your message here:", placeholder="Many Congratulations ....") | |
if st.button("Submit Message"): | |
if message: | |
st.success("Thank you for your message! ") | |
st.write(f"Your message: {message}") | |
else: | |
st.warning("Please write a message before submitting.") | |
# Footer | |
st.markdown(""" | |
<style> | |
footer {visibility: hidden;} | |
footer:after { | |
content: 'Made with ❤️ using Streamlit'; | |
visibility: visible; | |
display: block; | |
text-align: center; | |
padding: 5px; | |
font-size: 14px; | |
color: gray; | |
} | |
</style> | |
""", unsafe_allow_html=True) | |