How to use the pyngrok.ngrok.connect function in pyngrok

To help you get started, we’ve selected a few pyngrok examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Drakkar-Software / OctoBot-Tentacles / Services / Services_bases / webhook_service / webhook_service.py View on Github external
def connect(port, protocol="http") -> str:
        """
        Create a new ngrok tunnel
        :param port: the tunnel local port
        :param protocol: the protocol to use
        :return: the ngrok url
        """
        return ngrok.connect(port, protocol)
github alexdlaird / air-quality-bot / devserver.py View on Github external
# Calling mock_dynamodb2() above hijacked the requests library, so using the responses
# library (that moto also used), add passthrus for HTTP requests that should still
# succeed in dev
responses.add_passthru("http://127.0.0.1")
responses.add_passthru("https://api.twilio.com")
responses.add_passthru("http://www.airnowapi.org")
responses.add_passthru("https://airnow.gov")

if USE_NGROK:
    # Get the dev server port (defaults to 5000 for Flask, can be overridden with `--port`
    # when starting the server
    port = sys.argv[sys.argv.index("--port") + 1] if "--port" in sys.argv else 5000

    # Open a ngrok tunnel to the dev server
    public_url = ngrok.connect(port)
    print(" * ngrok tunnel \"{}\" -> \"http://127.0.0.1:{}/\"".format(public_url, port))

    TWILIO_ACCOUNT_SID = os.environ.get("AIR_QUALITY_DEV_TWILIO_ACCOUNT_SID", None)
    TWILIO_AUTH_TOKEN = os.environ.get("AIR_QUALITY_DEV_TWILIO_AUTH_TOKEN", None)
    TWILIO_SMS_NUMBER = os.environ.get("AIR_QUALITY_DEV_TWILIO_SMS_NUMBER", None)

    # Update any base URLs or webhooks to use the public ngrok URL
    if TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN and TWILIO_SMS_NUMBER:
        callback_url = "{}/inbound".format(public_url)

        client = Client(TWILIO_ACCOUNT_SID, TWILIO_AUTH_TOKEN)
        phone_number_sid = client.incoming_phone_numbers.list(phone_number=TWILIO_SMS_NUMBER)[0].sid
        client.incoming_phone_numbers(phone_number_sid).update(sms_url=callback_url)


###################################################################################

pyngrok

A Python wrapper for ngrok.

MIT
Latest version published 9 days ago

Package Health Score

87 / 100
Full package analysis