-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHome.py
39 lines (24 loc) · 955 Bytes
/
Home.py
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
from datetime import timedelta
from pathlib import Path
import streamlit as st
import download_source
downloads = Path("downloads")
downloads.mkdir(exist_ok=True)
@st.cache_resource(ttl=timedelta(hours=6), show_spinner="Getting latest version info...")
def get_latest_release() -> download_source.ReleaseInfo:
return download_source.get_latest_release()
def download(url: str, file_name: str) -> None:
with st.spinner(f"Loading {file_name}..."):
download_source.download_file(url, downloads / file_name)
st.write(f"File {file_name} loaded")
latest_release_info = get_latest_release()
st.write("Latest release:", latest_release_info.name)
url = latest_release_info.classic_win_small_url
file_name = url.rpartition("/")[2]
if (downloads / file_name).is_file():
st.write(f"File {file_name} already loaded")
else:
download(url, file_name)
button = st.button("Download again")
if button:
download(url, file_name)