OzoneAsai commited on
Commit
79cd54f
·
1 Parent(s): 100a960

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -7
app.py CHANGED
@@ -18,6 +18,13 @@ def save_uploaded_files(uploaded_files):
18
  file_paths.append(file_path)
19
  return file_paths
20
 
 
 
 
 
 
 
 
21
  if uploaded_files:
22
  file_paths = save_uploaded_files(uploaded_files)
23
  else:
@@ -73,10 +80,3 @@ if file_paths:
73
  st.markdown(get_binary_file_downloader_html(zip_filename), unsafe_allow_html=True)
74
 
75
  st.success("ファイルがアップロードされました。このページのURLを他のクライアントと共有してください。")
76
-
77
- # ダウンロード用のHTMLを生成
78
- def get_binary_file_downloader_html(file_path):
79
- with open(file_path, 'rb') as f:
80
- data = f.read()
81
- b64 = base64.b64encode(data).decode()
82
- return f'<a href="data:application/zip;base64,{b64}" download="{file_path}">ダウンロード</a>'
 
18
  file_paths.append(file_path)
19
  return file_paths
20
 
21
+ # ダウンロード用のHTMLを生成
22
+ def get_binary_file_downloader_html(file_path):
23
+ with open(file_path, 'rb') as f:
24
+ data = f.read()
25
+ b64 = base64.b64encode(data).decode()
26
+ return f'<a href="data:application/zip;base64,{b64}" download="{file_path}">ダウンロード</a>'
27
+
28
  if uploaded_files:
29
  file_paths = save_uploaded_files(uploaded_files)
30
  else:
 
80
  st.markdown(get_binary_file_downloader_html(zip_filename), unsafe_allow_html=True)
81
 
82
  st.success("ファイルがアップロードされました。このページのURLを他のクライアントと共有してください。")