Jimmyzheng-10 commited on
Commit
11d5ed8
·
1 Parent(s): cc22292
Files changed (1) hide show
  1. app.py +11 -4
app.py CHANGED
@@ -256,13 +256,20 @@ allowed_paths = [
256
 
257
  # Add all example file paths to allowed_paths to ensure they are accessible
258
  for example in examples_data:
259
- example_path = Path(example[0]).parent
260
- if str(example_path) not in allowed_paths:
261
- allowed_paths.append(str(example_path))
 
 
 
262
 
263
  print("Allowed paths for file serving:")
264
  for path in allowed_paths:
265
  print(f" - {path}")
266
 
267
  if __name__ == "__main__":
268
- demo.launch(allowed_paths=allowed_paths)
 
 
 
 
 
256
 
257
  # Add all example file paths to allowed_paths to ensure they are accessible
258
  for example in examples_data:
259
+ # HF Spaces: Ensure the path is absolute by joining with base_dir
260
+ # The example path is relative, so we join it with the base_dir to make it absolute.
261
+ example_abs_path = (base_dir / example[0]).resolve()
262
+ example_dir = example_abs_path.parent
263
+ if str(example_dir) not in allowed_paths:
264
+ allowed_paths.append(str(example_dir))
265
 
266
  print("Allowed paths for file serving:")
267
  for path in allowed_paths:
268
  print(f" - {path}")
269
 
270
  if __name__ == "__main__":
271
+ demo.launch(
272
+ server_name="0.0.0.0",
273
+ server_port=7860,
274
+ allowed_paths=allowed_paths
275
+ )