Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QR Code [Feature Request] #473

Open
zachgibson opened this issue Jan 25, 2018 · 3 comments
Open

QR Code [Feature Request] #473

zachgibson opened this issue Jan 25, 2018 · 3 comments

Comments

@zachgibson
Copy link

It’d be amazing to have the CLI generate a QR code to scan and open the URL.

@Sjeanpierre
Copy link

Hi I know this isn't exactly what you asked for, but this is a temporary solution that might help you,

this will create and ngrok connection and open your browser to the QR code for the connection.

ngrok http 8080 > /dev/null &2>1; open $(curl -s http://localhost:4040/api/tunnels | jq ".tunnels[1].public_url" | xargs -I{} echo "https://chart.googleapis.com/chart?cht=qr&chl={}&chs=180x180&choe=UTF-8&chld=L|2")

and a slightly more portable version, in case jq isn't installed

ngrok http 8080 > /dev/null &2>1; open $(curl -s http://localhost:4040/api/tunnels | egrep -o 'https:\/\/.{8}.ngrok.io' | xargs -I{} echo "https://chart.googleapis.com/chart?cht=qr&chl={}&chs=180x180&choe=UTF-8&chld=L|2")

@osteele
Copy link

osteele commented Jul 28, 2018

PR #472 looks like it implements this. It's currently failing CI, and un-merged.

@Lokeshwaran-M
Copy link

try this make it as a cli command and pass the port number as argument

import ngrok  
import qrcode

# Create an ngrok tunnel and get the public URL
tunnel = ngrok.connect(5000, authtoken_from_env=True)
print (f"Terminal Tunal Url : {tunnel.url()}")

# Get the public URL of the tunnel
public_url = tunnel.url()

# Generate a QR code for the ngrok URL
qr = qrcode.QRCode(
    version=1,
    error_correction=qrcode.constants.ERROR_CORRECT_L,
    box_size=10,
    border=4,
)
qr.add_data(public_url)
qr.make(fit=True)

# Save the QR code as an image
img = qr.make_image(fill_color="black", back_color="white")
img.save('ngrok_qr.png')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants