w3robotics commited on
Commit
55c2f3f
·
verified ·
1 Parent(s): 8dba553

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -17
app.py CHANGED
@@ -1,28 +1,26 @@
1
  import streamlit as st
2
  import os
3
 
4
- x = st.slider('Select a value')
5
- st.write(x, 'squared is', x * x)
6
-
7
-
8
  path = "/data"
9
 
10
- # Check if the directory already exists
11
- if not os.path.exists(path):
12
- os.mkdir(path)
13
- st.write(f"Directory '{path}' created")
14
- else:
15
- st.write(f"Directory '{path}' already exists")
 
 
 
 
16
 
 
 
 
 
 
17
 
18
 
19
- uploaded_file = st.file_uploader("Upload File")
20
- if uploaded_file is not None:
21
- file_details = {"FileName":uploaded_file.name,"FileType":uploaded_file.type}
22
- st.write(file_details)
23
- with open(os.path.join(path,uploaded_file.name),"wb") as f:
24
- f.write(uploaded_file.getbuffer())
25
- st.success("Saved File")
26
 
27
 
28
 
 
1
  import streamlit as st
2
  import os
3
 
 
 
 
 
4
  path = "/data"
5
 
6
+ # Define the modal dialog function
7
+ @st.dialog("Upload a File")
8
+ def upload_file():
9
+ uploaded_file = st.file_uploader("Choose a file")
10
+ if uploaded_file is not None:
11
+ file_details = {"FileName":uploaded_file.name,"FileType":uploaded_file.type}
12
+ st.write(file_details)
13
+ with open(os.path.join(path,uploaded_file.name),"wb") as f:
14
+ f.write(uploaded_file.getbuffer())
15
+ st.success("Saved File")
16
 
17
+ # Main app
18
+ st.write("Click the button to open the file upload dialog.")
19
+
20
+ if st.button("Open File Dialog"):
21
+ upload_file()
22
 
23
 
 
 
 
 
 
 
 
24
 
25
 
26