File size: 1,773 Bytes
971a845
 
 
d1ac52b
971a845
974f2d5
971a845
d1ac52b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
971a845
d1ac52b
 
 
 
 
 
971a845
d1ac52b
971a845
974f2d5
d1ac52b
 
971a845
d1ac52b
 
 
 
 
 
 
971a845
 
2a2e133
 
971a845
 
 
d1ac52b
 
971a845
 
d1ac52b
971a845
 
d1ac52b
 
4614dae
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import streamlit as st
import os
from glob import glob
import time

st.set_page_config(initial_sidebar_state="collapsed", page_title='File Upload')

#Hide header style
hide_st_style = """
<style>
#MainMenu {visibility: hidden;},
footer {visibility: hidden;},
header {visibility: hidden;}
[data-testid="collapsedControl"] {
        display: none
    }
[data-testid="stHeader"] {
        display: none
    }
.st-emotion-cache-1y4p8pa {
    width: 100%;
    padding: 1rem 1rem 10rem;
    max-width: 46rem;
}

[data-testid="stButton"]{
margin-top: 5px;
}
}
</style>
"""

st.markdown(hide_st_style, unsafe_allow_html = True)

st.title("File Upload")

uploaded_file = st.file_uploader("Choose a file to upload", accept_multiple_files=True)


if uploaded_file is not None:
    for u_file in uploaded_file:
        bytes_data = u_file.read()
        with open(os.path.join(os.getcwd(),"files",u_file.name.replace(" ", "_")),"wb") as f:
            f.write(u_file.getbuffer())
    st.success("File Uploaded")

st.header("Available Files")
st.caption("Meteo Rama")


files_list = glob(os.path.join(os.getcwd(),"files","*.*"))

table_html = "<table border=1 width=100%><th>FileName</th><th>Uploaded On</th><th>Show</th>"

for file in files_list:
    with open(file, 'rb') as f:
        table_html = table_html + f"<tr><td>{os.path.basename(file)}</td><td>{time.ctime(os.path.getctime(file))}</td><td><a href='Show_File?name={os.path.basename(file)}'>Show</a></td></tr>"


st.markdown(table_html + "</table>", unsafe_allow_html=True)

if st.button("Delete All Files"):
    files_list = glob(os.path.join(os.getcwd(),"files","*.*"))
    for f in files_list:


        if(os.path.exists(f)):
            os.remove(f)

    st.info("All files deleted!!! Refresh the page to see changes.")