xp3857 commited on
Commit
892925c
·
1 Parent(s): 5652deb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -6
app.py CHANGED
@@ -98,10 +98,11 @@ def get_f(r_name,spaces,token):
98
  t_file.close()
99
  files_b.append(f'{uid}/{space}-{file}')
100
  print(file)
101
- #spaces_b.append(files_b)
102
- #with zipfile.ZipFile('new.zip', 'w') as new_zip:
103
- # new_zip.write('spam.txt', compress_type=zipfile.ZIP_DEFLATED)
104
- return(files_b)
 
105
 
106
  def build_space(token,r_name,s_name,d_app,uu):
107
  if token==None or token=="":
@@ -174,7 +175,9 @@ with gr.Blocks() as build:
174
  with gr.Row():
175
  ss_name = gr.Dropdown(label="Spaces", choices=[],multiselect=True)
176
  f_btn=gr.Button()
177
- a_files=gr.File()
 
 
178
 
179
  with gr.Row():
180
  r_t=gr.Textbox(max_lines=100)
@@ -185,7 +188,7 @@ with gr.Blocks() as build:
185
  def cyc(x):
186
  return x,None
187
 
188
- f_btn.click(get_f,[r_name,ss_name,token],a_files)
189
  r_t.change(cyc,r_t,[m_t,files])
190
 
191
  s_btn.click(show_s,r_name,[s_name,ss_name])
 
98
  t_file.close()
99
  files_b.append(f'{uid}/{space}-{file}')
100
  print(file)
101
+ with zipfile.ZipFile(f'{space}.zip', 'w') as new_zip:
102
+ new_zip.write(f'{uid}/{file}', compress_type=zipfile.ZIP_DEFLATED)
103
+ spaces_b.append(new_zip)
104
+
105
+ return(files_b,spaces_b)
106
 
107
  def build_space(token,r_name,s_name,d_app,uu):
108
  if token==None or token=="":
 
175
  with gr.Row():
176
  ss_name = gr.Dropdown(label="Spaces", choices=[],multiselect=True)
177
  f_btn=gr.Button()
178
+ with gr.Row():
179
+ a_files=gr.File()
180
+ z_files=gr.File()
181
 
182
  with gr.Row():
183
  r_t=gr.Textbox(max_lines=100)
 
188
  def cyc(x):
189
  return x,None
190
 
191
+ f_btn.click(get_f,[r_name,ss_name,token],[a_files,z_files])
192
  r_t.change(cyc,r_t,[m_t,files])
193
 
194
  s_btn.click(show_s,r_name,[s_name,ss_name])