Spaces:
Runtime error
Runtime error
Commit
·
c24f025
1
Parent(s):
fed5513
Update app.py
Browse files
app.py
CHANGED
@@ -1,30 +1,36 @@
|
|
1 |
"""This files enables serving Panel apps on Hugging Face Spaces"""
|
2 |
-
import
|
3 |
-
from subprocess import Popen
|
4 |
|
5 |
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
APP,
|
18 |
-
"--port",
|
19 |
-
PORT,
|
20 |
-
"--host",
|
21 |
-
ADDRESS,
|
22 |
-
"--log-level-uvicorn",
|
23 |
-
"debug"
|
24 |
-
]
|
25 |
-
#if os.name != "nt":
|
26 |
-
# command = command + ["--num-procs", "4", "--num-threads", "4"]
|
27 |
|
28 |
-
|
29 |
-
|
30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
"""This files enables serving Panel apps on Hugging Face Spaces"""
|
2 |
+
import solara
|
|
|
3 |
|
4 |
|
5 |
+
@solara.component
|
6 |
+
def Page():
|
7 |
+
clicks, set_clicks = solara.use_state(0)
|
8 |
+
return solara.VBox(
|
9 |
+
[
|
10 |
+
solara.Button("Click me", on_click=lambda: set_clicks(clicks + 1)),
|
11 |
+
solara.Text(f"Clicks: {clicks}"),
|
12 |
+
]
|
13 |
+
)
|
14 |
|
15 |
+
def run(*,port=8877, host=None):
|
16 |
+
import os
|
17 |
+
if host is None:
|
18 |
+
host = os.environ.get("HOST")
|
19 |
+
if host is None:
|
20 |
+
host = os.getenv("GRADIO_SERVER_NAME")
|
21 |
+
if host is None:
|
22 |
+
host = "localhost"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
|
24 |
+
os.environ["SOLARA_APP"] = "__main__"
|
25 |
+
|
26 |
+
import uvicorn
|
27 |
+
from .server.starlette import app as asgi_app
|
28 |
+
|
29 |
+
config = uvicorn.Config(
|
30 |
+
app=asgi_app,
|
31 |
+
host=host,
|
32 |
+
port=port,
|
33 |
+
)
|
34 |
+
server = uvicorn.Server(config=config)
|
35 |
+
server.run()
|
36 |
+
run()
|