Zeel commited on
Commit
622bc33
1 Parent(s): 04bf9e0

handle Drive URLs correctly.

Browse files
Files changed (1) hide show
  1. app.py +9 -0
app.py CHANGED
@@ -243,6 +243,15 @@ if file_url is None:
243
 
244
  if file_url is None:
245
  st.stop()
 
 
 
 
 
 
 
 
 
246
  buffer = st.number_input("Buffer (m)", value=50, min_value=0, step=1)
247
 
248
  input_gdf = preprocess_gdf(gpd.read_file(file_url))
 
243
 
244
  if file_url is None:
245
  st.stop()
246
+
247
+ if isinstance(file_url, str):
248
+ if file_url.startswith("https://drive.google.com/file/d/"):
249
+ ID = file_url.replace("https://drive.google.com/file/d/", "").split("/")[0]
250
+ file_url = f"https://drive.google.com/uc?id={ID}"
251
+ elif file_url.startswith("https://drive.google.com/open?id="):
252
+ ID = file_url.replace("https://drive.google.com/open?id=", "")
253
+ file_url = f"https://drive.google.com/uc?id={ID}"
254
+
255
  buffer = st.number_input("Buffer (m)", value=50, min_value=0, step=1)
256
 
257
  input_gdf = preprocess_gdf(gpd.read_file(file_url))