TarunEnma commited on
Commit
c1e2c12
·
verified ·
1 Parent(s): 0b86c5d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -0
app.py CHANGED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+
3
+ class TextLoader:
4
+ def __init__(self, file):
5
+ self.file = file
6
+ def load(self):
7
+ return self.file.read().decode("utf-8")
8
+
9
+ st.title("Please upload files that are txt format")
10
+ uploaded_file = st.file_uploader("Choose a text file", type=["txt"])
11
+
12
+ if uploaded_file is not None:
13
+ with open("uploaded_file.txt", "wb") as f:
14
+ f.write(uploaded_file.getbuffer())
15
+
16
+ text_loader = TextLoader(open("uploaded_file.txt","rb"))
17
+ file_content = text_loader.load()
18
+
19
+ st.write("File content:")
20
+ st.text(file_content)