Spaces:
Sleeping
Sleeping
Commit
·
6272921
1
Parent(s):
8cb9b81
Use web_server for Gradio deployment on Modal
Browse filesMore reliable than asgi_app for Gradio apps.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
- modal_app.py +7 -9
modal_app.py
CHANGED
|
@@ -31,17 +31,15 @@ image = (
|
|
| 31 |
modal.Secret.from_name("elevenlabs-api-key"),
|
| 32 |
],
|
| 33 |
timeout=600,
|
|
|
|
| 34 |
)
|
| 35 |
-
@modal.
|
| 36 |
-
@modal.asgi_app()
|
| 37 |
def serve():
|
| 38 |
-
"""Serve the Gradio app
|
| 39 |
-
import
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
gradio_app = create_app()
|
| 44 |
-
return gradio_app
|
| 45 |
|
| 46 |
|
| 47 |
# For local testing
|
|
|
|
| 31 |
modal.Secret.from_name("elevenlabs-api-key"),
|
| 32 |
],
|
| 33 |
timeout=600,
|
| 34 |
+
container_idle_timeout=300,
|
| 35 |
)
|
| 36 |
+
@modal.web_server(port=7860, startup_timeout=120)
|
|
|
|
| 37 |
def serve():
|
| 38 |
+
"""Serve the Gradio app via web_server."""
|
| 39 |
+
import subprocess
|
| 40 |
+
import os
|
| 41 |
+
os.chdir("/app")
|
| 42 |
+
subprocess.Popen(["python", "app.py"])
|
|
|
|
|
|
|
| 43 |
|
| 44 |
|
| 45 |
# For local testing
|