Skip to content

Commit

Permalink
zip file autoload
Browse files Browse the repository at this point in the history
  • Loading branch information
insolor committed Oct 31, 2023
1 parent 182ec46 commit f8e93e8
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions Home.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,22 @@ def get_latest_release():
url = latest_release_info.classic_win_small_url
file_name = url.rpartition("/")[2]

if Path(file_name).is_file():
st.write("File already loaded")
download_button_text = "Download again"
else:
download_button_text = "Download"

button = st.button(download_button_text)

if button:
def download(url, file_name):
st.write("Loading...")

response = requests.get(url)
response.raise_for_status()

Path(file_name).open("wb").write(response.content)
st.write(f"File {file_name} loaded")


st.write("Loaded.")
if Path(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)

0 comments on commit f8e93e8

Please sign in to comment.