Spaces:
Running on Zero
Running on Zero
fix(ui): allowed_paths includes ComfyUI output dir so generated videos display
Browse filesGradio 5 refuses to serve files outside cwd/tempdir/allowed_paths.
On Spaces, ComfyUI writes to ~/comfyui/output/ which is outside the app
cwd, causing InvalidPathError on first Generate. Whitelist the output
directory at launch and pre-create it so cold-start mkdir never races.
app.py
CHANGED
|
@@ -783,5 +783,21 @@ def _make_handler(mode_name: str, h: dict):
|
|
| 783 |
|
| 784 |
|
| 785 |
if __name__ == "__main__":
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 786 |
app = build_app()
|
| 787 |
-
app.launch(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 783 |
|
| 784 |
|
| 785 |
if __name__ == "__main__":
|
| 786 |
+
# Gradio 5's file-access policy refuses to serve files outside cwd /
|
| 787 |
+
# tempdir / allowed_paths. ComfyUI writes generated videos to
|
| 788 |
+
# `<comfy_dir>/output/...` which is outside our cwd on Spaces, so
|
| 789 |
+
# whitelist that directory tree explicitly.
|
| 790 |
+
_on_spaces_at_launch = bool(os.environ.get("SPACES_ZERO_GPU"))
|
| 791 |
+
_comfy_dir_at_launch = (
|
| 792 |
+
(pathlib.Path.home() / "comfyui") if _on_spaces_at_launch
|
| 793 |
+
else pathlib.Path(__file__).parent / "comfyui"
|
| 794 |
+
)
|
| 795 |
+
_output_dir = _comfy_dir_at_launch / "output"
|
| 796 |
+
_output_dir.mkdir(parents=True, exist_ok=True)
|
| 797 |
+
|
| 798 |
app = build_app()
|
| 799 |
+
app.launch(
|
| 800 |
+
server_name="0.0.0.0",
|
| 801 |
+
server_port=7860,
|
| 802 |
+
allowed_paths=[str(_output_dir)],
|
| 803 |
+
)
|