How services running on your Space can be shared securely from a browser
You can use your Space to create software, work on a dataset, or collaborate on a machine learning algorithm. Sometimes you want to share what your working on from your Space for others to view it from a browser, for example, Streamlit, Gradio, Marimo, or your own web application.
This section explains how you can share services from your Space. All services are shared using an end-to-end encrypted connection in a zero-trust network.
You use the PairSpaces CLI to open a port from your Cloud Space. You open a port using pair spaces update SPACE_ID --port PORT_NUMBER
from the Cloud Space. The PairSpaces CLI is installed on every Cloud Space.
Let's demonstrate this by serving a FastAPI application from a Cloud Space.
First, install pip
in your Space.
> curl -O https://bootstrap.pypa.io/get-pip.py
> python3 get-pip.py
Then, use the FastAPI documentation from here to serve their example application. From your Space, use the following command to start the FastAPI service:
> fastapi dev main.py
Next, open port 8000 on your Cloud Space.
> pair spaces update SPACE_ID --port 8000
Your Space is now available on port 8000. To allow connections, run:
> pair keys create
> pair spaces connect SPACE_ID --port 8000
And follow the instructions provided in the output above. If you haven't already, run pair keys create
followed by pair spaces connect SPACE_ID --port 8000
.
> pair keys create
> pair spaces connect SPACE_ID --port 8000
Your team can access your shared service from their machines using the following commands.
> pair keys create
> pair spaces connect SPACE_ID --port 8000
Forwarding connection [68704fdcf60bbb90e2b801f3:8000] to http://localhost:8000
> pair keys create
> pair spaces connect SPACE_ID --port 8000
Forwarding connection [68704fdcf60bbb90e2b801f3:8000] to http://localhost:8000
> pair.exe keys create
> pair.exe spaces connect SPACE_ID --port 8000
Forwarding connection [68704fdcf60bbb90e2b801f3:8000] to http://localhost:8000
They can view the service by navigating to http://localhost:8000/docs
.
This service will only be accessible to you and any team members you shared your Cloud Space with.
You use the PairSpaces CLI to share a service running on your local machine. You open a port using pair spaces update SPACE_ID --port PORT
from your local machine.
And follow the instructions provided in the output above. If you haven't already, run pair keys create
followed by pair spaces connect SPACE_ID --port PORT
.
> pair keys create
> pair spaces connect SPACE_ID --port PORT
Your team can access your shared service from their machines using the following commands.
> pair keys create
> pair spaces connect SPACE_ID --port PORT
Forwarding connection [68704fdcf60bbb90e2b801f3:PORT] to http://localhost:PORT
> pair keys create
> pair spaces connect SPACE_ID --port PORT
Forwarding connection [68704fdcf60bbb90e2b801f3:PORT] to http://localhost:PORT
> pair.exe keys create
> pair.exe spaces connect SPACE_ID --port PORT
Forwarding connection [68704fdcf60bbb90e2b801f3:PORT] to http://localhost:PORT
They can view the service by navigating to http://localhost:PORT
.
This service will only be accessible to you and any team members you shared your Local Space with.