From f8e93e8aba72a9d24bb47ad975360cea50bb0eba Mon Sep 17 00:00:00 2001 From: insolor Date: Tue, 31 Oct 2023 19:53:37 +0300 Subject: [PATCH] zip file autoload --- Home.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/Home.py b/Home.py index e604191..e4ac466 100644 --- a/Home.py +++ b/Home.py @@ -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)