Kelbec commited on
Commit
8c05209
1 Parent(s): 60e9b44

upload zip file enabled

Browse files
Files changed (1) hide show
  1. pages/01_dcascade.py +8 -1
pages/01_dcascade.py CHANGED
@@ -175,12 +175,19 @@ def Page():
175
  f = file["file_obj"]
176
  set_content(f.read())
177
  set_uploaded(False)
 
178
 
179
  def upload_file():
180
  if content:
 
181
  file_path = os.path.join("public",filename)
182
  with open(file_path,"wb") as file:
183
  file.write(content)
 
 
 
 
 
184
  set_uploaded(True)
185
 
186
  def open_river_file():
@@ -238,7 +245,7 @@ def Page():
238
  if map_loaded:
239
  MapComponent()
240
  with solara.Card("Upload files"):
241
- solara.Markdown("Required \*.shp, \*.shx, \*.dbf and \*.prj files for **river** file and \*.csv for **q** file. (one at the time)")
242
  with solara.ColumnsResponsive(1, large=6):
243
  solara.FileDrop(
244
  label="Drag and drop a file here ",
 
175
  f = file["file_obj"]
176
  set_content(f.read())
177
  set_uploaded(False)
178
+ print(file)
179
 
180
  def upload_file():
181
  if content:
182
+
183
  file_path = os.path.join("public",filename)
184
  with open(file_path,"wb") as file:
185
  file.write(content)
186
+ if filename.endswith(".zip"):
187
+ print(filename)
188
+ shutil.unpack_archive(os.getcwd()+"/public/"+filename,os.getcwd()+"/public")
189
+ os.remove(os.getcwd()+"/public/"+filename)
190
+
191
  set_uploaded(True)
192
 
193
  def open_river_file():
 
245
  if map_loaded:
246
  MapComponent()
247
  with solara.Card("Upload files"):
248
+ solara.Markdown("Required \*.shp, \*.shx, \*.dbf and \*.prj files for **river** file and \*.csv for **q** file. Upload files one at the time or compressed in a *zip* archive.")
249
  with solara.ColumnsResponsive(1, large=6):
250
  solara.FileDrop(
251
  label="Drag and drop a file here ",