Spaces:
Runtime error
Runtime error
fix: update app.py with dynamic port
Browse files
app.py
CHANGED
|
@@ -1,31 +1,37 @@
|
|
| 1 |
-
import os
|
| 2 |
-
import gradio.routes
|
| 3 |
-
|
| 4 |
-
# Enable SVG rendering in Gradio
|
| 5 |
-
gradio.routes.XSS_SAFE_MIMETYPES.add("image/svg+xml")
|
| 6 |
-
|
| 7 |
-
from theflow.settings import settings as flowsettings
|
| 8 |
-
|
| 9 |
-
KH_APP_DATA_DIR = getattr(flowsettings, "KH_APP_DATA_DIR", ".")
|
| 10 |
-
KH_GRADIO_SHARE = getattr(flowsettings, "KH_GRADIO_SHARE", False)
|
| 11 |
-
GRADIO_TEMP_DIR = os.getenv("GRADIO_TEMP_DIR", None)
|
| 12 |
-
# override GRADIO_TEMP_DIR if it's not set
|
| 13 |
-
if GRADIO_TEMP_DIR is None:
|
| 14 |
-
GRADIO_TEMP_DIR = os.path.join(KH_APP_DATA_DIR, "gradio_tmp")
|
| 15 |
-
os.environ["GRADIO_TEMP_DIR"] = GRADIO_TEMP_DIR
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
from ktem.main import App # noqa
|
| 19 |
-
|
| 20 |
-
app = App()
|
| 21 |
-
demo = app.make()
|
| 22 |
-
demo.title = app.app_name
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import gradio.routes
|
| 3 |
+
|
| 4 |
+
# Enable SVG rendering in Gradio
|
| 5 |
+
gradio.routes.XSS_SAFE_MIMETYPES.add("image/svg+xml")
|
| 6 |
+
|
| 7 |
+
from theflow.settings import settings as flowsettings
|
| 8 |
+
|
| 9 |
+
KH_APP_DATA_DIR = getattr(flowsettings, "KH_APP_DATA_DIR", ".")
|
| 10 |
+
KH_GRADIO_SHARE = getattr(flowsettings, "KH_GRADIO_SHARE", False)
|
| 11 |
+
GRADIO_TEMP_DIR = os.getenv("GRADIO_TEMP_DIR", None)
|
| 12 |
+
# override GRADIO_TEMP_DIR if it's not set
|
| 13 |
+
if GRADIO_TEMP_DIR is None:
|
| 14 |
+
GRADIO_TEMP_DIR = os.path.join(KH_APP_DATA_DIR, "gradio_tmp")
|
| 15 |
+
os.environ["GRADIO_TEMP_DIR"] = GRADIO_TEMP_DIR
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
from ktem.main import App # noqa
|
| 19 |
+
|
| 20 |
+
app = App()
|
| 21 |
+
demo = app.make()
|
| 22 |
+
demo.title = app.app_name
|
| 23 |
+
|
| 24 |
+
server_name = os.environ.get("GRADIO_SERVER_NAME", "0.0.0.0")
|
| 25 |
+
server_port = int(os.environ.get("PORT", os.environ.get("GRADIO_SERVER_PORT", 7860)))
|
| 26 |
+
|
| 27 |
+
demo.queue().launch(
|
| 28 |
+
server_name=server_name,
|
| 29 |
+
server_port=server_port,
|
| 30 |
+
favicon_path=app._favicon,
|
| 31 |
+
inbrowser=False,
|
| 32 |
+
allowed_paths=[
|
| 33 |
+
os.path.abspath("libs/ktem/ktem/assets"),
|
| 34 |
+
os.path.abspath(GRADIO_TEMP_DIR),
|
| 35 |
+
],
|
| 36 |
+
share=KH_GRADIO_SHARE,
|
| 37 |
+
)
|