update ngrok_connect

This commit is contained in:
josc146 2023-11-04 20:22:28 +08:00
parent 1dcda47013
commit 47b0c35441

View File

@ -1,11 +1,13 @@
import os import os
import sys import global_var
def ngrok_connect(): def ngrok_connect():
from pyngrok import ngrok, conf from pyngrok import ngrok, conf
conf.set_default(conf.PyngrokConfig(ngrok_path="./ngrok")) conf.set_default(
conf.PyngrokConfig(ngrok_path="./ngrok.exe" if os.name == "nt" else "./ngrok")
)
ngrok.set_auth_token(os.environ["ngrok_token"]) ngrok.set_auth_token(os.environ["ngrok_token"])
http_tunnel = ngrok.connect(8000 if len(sys.argv) == 1 else int(sys.argv[1])) http_tunnel = ngrok.connect(global_var.get(global_var.Args).port)
print(http_tunnel.public_url) print(f"ngrok url: {http_tunnel.public_url}")