File size: 1,069 Bytes
3aa52f9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import os
import gradio.routes

# Enable SVG rendering in Gradio
gradio.routes.XSS_SAFE_MIMETYPES.add("image/svg+xml")

from theflow.settings import settings as flowsettings

KH_APP_DATA_DIR = getattr(flowsettings, "KH_APP_DATA_DIR", ".")
KH_GRADIO_SHARE = getattr(flowsettings, "KH_GRADIO_SHARE", False)
GRADIO_TEMP_DIR = os.getenv("GRADIO_TEMP_DIR", None)
# override GRADIO_TEMP_DIR if it's not set
if GRADIO_TEMP_DIR is None:
    GRADIO_TEMP_DIR = os.path.join(KH_APP_DATA_DIR, "gradio_tmp")
    os.environ["GRADIO_TEMP_DIR"] = GRADIO_TEMP_DIR


from ktem.main import App  # noqa

app = App()
demo = app.make()
demo.title = app.app_name

server_name = os.environ.get("GRADIO_SERVER_NAME", "0.0.0.0")
server_port = int(os.environ.get("PORT", os.environ.get("GRADIO_SERVER_PORT", 7860)))

demo.queue().launch(
    server_name=server_name,
    server_port=server_port,
    favicon_path=app._favicon,
    inbrowser=False,
    allowed_paths=[
        os.path.abspath("libs/ktem/ktem/assets"),
        os.path.abspath(GRADIO_TEMP_DIR),
    ],
    share=KH_GRADIO_SHARE,
)