dhiraj5678 commited on
Commit
8df8e49
1 Parent(s): dac3c9d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -6
app.py CHANGED
@@ -7,10 +7,18 @@ model = AutoModelForSeq2SeqLM.from_pretrained("facebook/bart-large-cnn")
7
  import streamlit as st
8
  import os
9
 
10
- def file_selector(folder_path='.'):
11
- filenames = os.listdir(folder_path)
12
- selected_filename = st.selectbox('Select a file', filenames)
13
- return os.path.join(folder_path, selected_filename)
 
14
 
15
- filename = file_selector()
16
- st.write('You selected `%s`' % filename)
 
 
 
 
 
 
 
 
7
  import streamlit as st
8
  import os
9
 
10
+ uploaded_file = st.file_uploader("Choose a file")
11
+ if uploaded_file is not None:
12
+ # To read file as bytes:
13
+ bytes_data = uploaded_file.getvalue()
14
+ st.write(bytes_data)
15
 
16
+ # To convert to a string based IO:
17
+ stringio = StringIO(uploaded_file.getvalue().decode("utf-8"))
18
+ st.write(stringio)
19
+
20
+ # To read file as string:
21
+ string_data = stringio.read()
22
+ st.write(string_data)
23
+
24
+