ccclllwww commited on
Commit
0b52abf
·
verified ·
1 Parent(s): 2397706

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -18
app.py CHANGED
@@ -1,29 +1,34 @@
1
  import streamlit as st
2
- import time
3
  from PIL import Image
 
4
 
5
  # Title of the app
6
  st.title("Streamlit Demo App")
7
 
8
- # Welcome message
9
- st.write("Welcome to my Streamlit demo app! Here you can upload a file, view images, and play audio.")
10
 
11
- # File uploader
12
- uploaded_file = st.file_uploader("Choose a file", type=['jpg', 'png', 'mp3'])
13
- if uploaded_file is not None:
14
- st.write("File uploaded:", uploaded_file.name)
15
 
16
- # Display an image
17
- if uploaded_file is not None and uploaded_file.type in ["image/jpeg", "image/png"]:
18
  image = Image.open(uploaded_file)
19
- st.image(image, caption='Uploaded Image', use_column_width=True)
 
 
 
 
 
 
 
 
 
 
 
20
 
21
- # Button to trigger loading spinner
22
- if st.button('Start Loading'):
23
- with st.spinner("Loading..."):
24
- time.sleep(2) # Simulating a long computation
25
- st.success("Loading complete!")
26
 
27
- # Play an audio file if uploaded
28
- if uploaded_file is not None and uploaded_file.type == "audio/mpeg":
29
- st.audio(uploaded_file)
 
1
  import streamlit as st
 
2
  from PIL import Image
3
+ import time
4
 
5
  # Title of the app
6
  st.title("Streamlit Demo App")
7
 
8
+ # Writing some text
9
+ st.write("Welcome to the Streamlit demo app! Here you can upload files, view images, and play audio.")
10
 
11
+ # File uploader for images
12
+ uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "jpeg", "png"])
 
 
13
 
14
+ if uploaded_file is not None:
15
+ # Display the uploaded image
16
  image = Image.open(uploaded_file)
17
+ st.image(image, caption='Uploaded Image.', use_column_width=True)
18
+
19
+ # Audio file uploader
20
+ audio_file = st.file_uploader("Choose an audio file...", type=["mp3", "wav"])
21
+
22
+ if audio_file is not None:
23
+ # Play the uploaded audio file
24
+ st.audio(audio_file)
25
+
26
+ # Using a spinner during a time-consuming task
27
+ with st.spinner('Loading...'):
28
+ time.sleep(2) # Simulating a long computation
29
 
30
+ st.success('Done!')
 
 
 
 
31
 
32
+ # Button to trigger an action
33
+ if st.button('Click me'):
34
+ st.write("You clicked the button!")