What is ngrok?
ngrok combines your reverse proxy, firewall, API gateway, and global load balancing to deliver apps and APIs.
Simply put, ngrok makes it easy to publish a web application running locally with a single command.
This is very useful to build prototyping.
For Google Colab, using ngrok would make things easy if you want to run an open source LLM and use it via an API server (like FastAPI, Flask etc).
How to use ngrok on Google Colab
There are 3 steps to use ngrok with Google Colab secret key.
- Download ngrok
- Set secret key
- Load secret key
Step1. Download ngrok
This step is pretty straightforward.
Download zip file for linux and unzip it.
!wget https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip
!unzip -o ngrok-stable-linux-amd64.zip
Step2. Set secret key
Click key icon in the sidebar and click Add a new secret
.
You will need to fill two text box. One is the key name and you can name whatever you want and the other is the key value or token. Then you need to click a toggle button to enable the key.
Step3. Load secret key
The following code is very simple, load the secret key and pass it to ngrok via ngrok's python package for authentication.
import os
from google.colab import userdata
from pyngrok import conf
os.environ["NGROK"] = userdata.get("NGROK")
conf.get_default().auth_token = os.environ["NGROK"]
These three steps will work for things that you need to pass a secret key or token on Google Colab.
Top comments (2)
now we need to see how to implement it into vagrant
???