Kongu B K Riot
Kongu B K Riot

Reputation: 117

How to Get ngrok https URL with pyngrok in Python

How would I write a Python program that automates ngrok connections? I've tried using pyngrok, but I want to display an https URL and it always returns http.

Upvotes: 0

Views: 5239

Answers (2)

Utku Can
Utku Can

Reputation: 995

For those who are using pyngrok version 4.1, passing the argument bind_tls= True directly will raise an error. Try using:

options = {
   "bind_tls": True
}


public_url = ngrok.connect(port='80',options=options)

That will work.

Upvotes: 0

alexdlaird
alexdlaird

Reputation: 1293

Per the pyngrok docs, two tunnels are opened by default, one http, one https. Just use bind_tls=True if you only want the https tunnel and it will be returned.

from pyngrok import ngrok

https_tunnel = ngrok.connect(bind_tls=True)

If you want to know how pyngrok does this, its code is open source.

Upvotes: 2

Related Questions