Spaces:
Running
Running
brentyi
commited on
Commit
·
43fe6c7
1
Parent(s):
cd95471
Revert some parts
Browse files- app.py +4 -4
- viser_proxy_manager.py +2 -11
app.py
CHANGED
@@ -8,7 +8,8 @@ from viser_proxy_manager import ViserProxyManager
|
|
8 |
|
9 |
|
10 |
def main() -> None:
|
11 |
-
|
|
|
12 |
|
13 |
# Create a Gradio interface with title, iframe, and buttons
|
14 |
with gr.Blocks(title="Viser Viewer") as demo:
|
@@ -62,9 +63,8 @@ def main() -> None:
|
|
62 |
assert request.session_hash is not None
|
63 |
viser_manager.stop_server(request.session_hash)
|
64 |
|
65 |
-
|
66 |
-
|
67 |
-
demo.block_thread()
|
68 |
|
69 |
|
70 |
if __name__ == "__main__":
|
|
|
8 |
|
9 |
|
10 |
def main() -> None:
|
11 |
+
app = fastapi.FastAPI()
|
12 |
+
viser_manager = ViserProxyManager(app)
|
13 |
|
14 |
# Create a Gradio interface with title, iframe, and buttons
|
15 |
with gr.Blocks(title="Viser Viewer") as demo:
|
|
|
63 |
assert request.session_hash is not None
|
64 |
viser_manager.stop_server(request.session_hash)
|
65 |
|
66 |
+
gr.mount_gradio_app(app, demo, "/")
|
67 |
+
uvicorn.run(app, host="0.0.0.0", port=7860)
|
|
|
68 |
|
69 |
|
70 |
if __name__ == "__main__":
|
viser_proxy_manager.py
CHANGED
@@ -14,6 +14,7 @@ class ViserProxyManager:
|
|
14 |
as well as proxying HTTP and WebSocket requests to the appropriate Viser server.
|
15 |
|
16 |
Args:
|
|
|
17 |
min_local_port: Minimum local port number to use for Viser servers. Defaults to 8000.
|
18 |
These ports are used only for internal communication and don't need to be publicly exposed.
|
19 |
max_local_port: Maximum local port number to use for Viser servers. Defaults to 9000.
|
@@ -22,22 +23,12 @@ class ViserProxyManager:
|
|
22 |
|
23 |
def __init__(
|
24 |
self,
|
|
|
25 |
min_local_port: int = 8000,
|
26 |
max_local_port: int = 9000,
|
27 |
) -> None:
|
28 |
self._min_port = min_local_port
|
29 |
self._max_port = max_local_port
|
30 |
-
|
31 |
-
def setup(
|
32 |
-
self,
|
33 |
-
app: FastAPI,
|
34 |
-
) -> None:
|
35 |
-
"""Set up the Viser proxy manager with the given FastAPI application.
|
36 |
-
This should be called after `demo.launch(prevent_thread_lock=True)`.
|
37 |
-
|
38 |
-
Args:
|
39 |
-
app: The FastAPI application to which the proxy routes will be added.
|
40 |
-
"""
|
41 |
self._server_from_session_hash: dict[str, viser.ViserServer] = {}
|
42 |
self._last_port = self._min_port - 1 # Track last port tried
|
43 |
|
|
|
14 |
as well as proxying HTTP and WebSocket requests to the appropriate Viser server.
|
15 |
|
16 |
Args:
|
17 |
+
app: The FastAPI application to which the proxy routes will be added.
|
18 |
min_local_port: Minimum local port number to use for Viser servers. Defaults to 8000.
|
19 |
These ports are used only for internal communication and don't need to be publicly exposed.
|
20 |
max_local_port: Maximum local port number to use for Viser servers. Defaults to 9000.
|
|
|
23 |
|
24 |
def __init__(
|
25 |
self,
|
26 |
+
app: FastAPI,
|
27 |
min_local_port: int = 8000,
|
28 |
max_local_port: int = 9000,
|
29 |
) -> None:
|
30 |
self._min_port = min_local_port
|
31 |
self._max_port = max_local_port
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
self._server_from_session_hash: dict[str, viser.ViserServer] = {}
|
33 |
self._last_port = self._min_port - 1 # Track last port tried
|
34 |
|