static url in pyngrok or ngrok in google colab

132 Views Asked by At

hey i am trying to run this code in google colab or other virtual machine and i need to make sure only static server instead of random url everytime generated is used for this one what should i do ?

**
!pip install flask pyngrok flask-ngrok
!ngrok authtoken {{my-auth-token}}
from flask import Flask
from pyngrok import ngrok
import os

app = Flask(name)

@app.route("/")
def home():
return "Hello from Flask"
public_url = ngrok.connect(5000, bind_tls=True)
print("Tracking URL:", public_url)

app.run() 
**

everytime i run i am not able to get a new server url but i need a static server provided by ngrok.

Thanks in advance

alteast somework around of what can i add to get a static url in free version as they have mentioned but i am not able to do so in google colab

1

There are 1 best solutions below

0
Nathan Reitinger On

You might be able to use this package (https://pypi.org/project/ngrok-flask-cart/). I built it for a separate project (https://github.com/nathanReitinger/CART/tree/main), but I think the ngrok-flask part applies here.

pip install ngrok-flask-cart
...
from ngrok_flask_cart import run_with_ngrok
...
run_with_ngrok(app=app, domain='--domain=<YOUR_STATIC_DOMAIN>', auth_token='<YOUR_AUTH_TOKEN>')