File size: 886 Bytes
1bf7a1c
c24f025
1bf7a1c
a400dc3
c24f025
 
 
 
 
 
 
 
 
1bf7a1c
c24f025
 
 
 
 
 
 
 
1bf7a1c
c24f025
 
 
61553c0
b6d499b
c24f025
 
 
 
 
 
 
 
adaa358
6224c0d
2f541b1
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
39
"""This files enables serving Panel apps on Hugging Face Spaces"""
import solara


@solara.component
def Page():
    clicks, set_clicks = solara.use_state(0)
    return solara.VBox(
        [
            solara.Button("Click me", on_click=lambda: set_clicks(clicks + 1)),
            solara.Text(f"Clicks: {clicks}"),
        ]
    )

def run(*,port=8877, host=None):
    import os
    if host is None:
        host = os.environ.get("HOST")
    if host is None:
        host = os.getenv("GRADIO_SERVER_NAME")
    if host is None:
        host = "localhost"

    os.environ["SOLARA_APP"] = "__main__"

    import uvicorn
    # force change
    from solara.server.starlette import app as asgi_app

    config = uvicorn.Config(
        app=asgi_app,
        host=host,
        port=port,
    )
    server = uvicorn.Server(config=config)
    server.run()

print("just run2!")
run(port=7860)