isom5240 commited on
Commit
f4f24b0
Β·
verified Β·
1 Parent(s): 8add8fb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -23
app.py CHANGED
@@ -2,26 +2,29 @@ import streamlit as st
2
  from PIL import Image
3
  import time
4
 
5
- st.title("πŸ“ File Uploader Demo")
6
-
7
- st.write("Upload an image or audio file, and we'll display or play it for you!")
8
-
9
- uploaded_file = st.file_uploader("Choose an image or audio file", type=["png", "jpg", "jpeg", "mp3", "wav"])
10
-
11
- if uploaded_file is not None:
12
- file_type = uploaded_file.type
13
-
14
- with st.spinner("Processing..."):
15
- time.sleep(2) # simulate processing time
16
-
17
- if "image" in file_type:
18
- st.write("### Uploaded Image:")
19
- image = Image.open(uploaded_file)
20
- st.image(image, caption="Your image", use_column_width=True)
21
-
22
- elif "audio" in file_type:
23
- st.write("### Uploaded Audio:")
24
- st.audio(uploaded_file, format=file_type)
25
-
26
- else:
27
- st.write("Unsupported file type.")
 
 
 
 
2
  from PIL import Image
3
  import time
4
 
5
+ # App title
6
+ st.title("Streamlit Demo on Hugging Face")
7
+
8
+ # Write some text
9
+ st.write("Welcome to a demo app showcasing basic Streamlit components!")
10
+
11
+ # File uploader for image and audio
12
+ uploaded_image = st.file_uploader("Upload an image", type=["jpg", "jpeg", "png"])
13
+ uploaded_audio = st.file_uploader("Upload an audio file", type=["mp3", "wav", "ogg"])
14
+
15
+ # Display image with spinner
16
+ if uploaded_image is not None:
17
+ with st.spinner("Loading image..."):
18
+ time.sleep(1) # Simulate a delay
19
+ image = Image.open(uploaded_image)
20
+ st.image(image, caption="Uploaded Image", use_column_width=True)
21
+
22
+ # Play audio with spinner
23
+ if uploaded_audio is not None:
24
+ with st.spinner("Loading audio..."):
25
+ time.sleep(1) # Simulate a delay
26
+ st.audio(uploaded_audio)
27
+
28
+ # Button interaction
29
+ if st.button("Click Me"):
30
+ st.write("πŸŽ‰ You clicked the button!")