File size: 1,074 Bytes
5a91fdd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import ngrok

from comfy.cli_args import args

# #########################################################
# Replace None on the line below this with your Authtoken.
# Your Authtoken can be found at https://dashboard.ngrok.com/get-started/your-authtoken
# Don't forget to enclose it in quotation marks!
# Example:
# ngrok_token = "DuMMyTOk3n38ty38nhbvgjbb_HEhdpnojhrbdpnrmE0jt"

ngrok_token = 2luGDduz0L8Szz4ZlDpryiMiW0n_6ZP5THZWJ9ohyHWwtS2Wy

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

print("### Load ngrok")

def connect():
    # Connect if ngrok token is set
    if ngrok_token is not None:
        print("trying to connect ngrok...\n")
        options = {"authtoken": ngrok_token, "session_metadata": "ComfyUI"}

        try:
            ngrok_url = ngrok.forward(f"{args.listen}:{args.port}", **options).url()
        except Exception as e:
            print("Failed to connect to ngrok.")
        else:
            print(f"\n\033[32m\033[1m##\n## Connection to ngrok established.\n##\n## URL: {ngrok_url}\n##\n\033[0m\033[0m")
            
connect()