Update webui.py
Browse files
webui.py
CHANGED
@@ -2,11 +2,36 @@ from __future__ import annotations
|
|
2 |
|
3 |
import os
|
4 |
import time
|
|
|
5 |
|
6 |
from modules import timer
|
7 |
from modules import initialize_util
|
8 |
from modules import initialize
|
9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
startup_timer = timer.startup_timer
|
11 |
startup_timer.record("launcher")
|
12 |
|
@@ -156,30 +181,6 @@ def webui():
|
|
156 |
|
157 |
if __name__ == "__main__":
|
158 |
|
159 |
-
#ngrok穿透
|
160 |
-
ngrok_use = True
|
161 |
-
ngrokTokenFile='/root/main/Authtoken.txt' # 非必填 存放ngrokToken的文件的路径
|
162 |
-
|
163 |
-
def ngrok_start(ngrokTokenFile: str, port: int, address_name: str, should_run: bool):
|
164 |
-
if not should_run:
|
165 |
-
print('Skipping ngrok start')
|
166 |
-
return
|
167 |
-
if Path(ngrokTokenFile).exists():
|
168 |
-
with open(ngrokTokenFile, encoding="utf-8") as nkfile:
|
169 |
-
ngrokToken = nkfile.readline()
|
170 |
-
print('use nrgok')
|
171 |
-
from pyngrok import conf, ngrok
|
172 |
-
conf.get_default().auth_token = ngrokToken
|
173 |
-
conf.get_default().monitor_thread = False
|
174 |
-
ssh_tunnels = ngrok.get_tunnels(conf.get_default())
|
175 |
-
if len(ssh_tunnels) == 0:
|
176 |
-
ssh_tunnel = ngrok.connect(port, bind_tls=True)
|
177 |
-
print(f'{address_name}:' + ssh_tunnel.public_url)
|
178 |
-
else:
|
179 |
-
print(f'{address_name}:' + ssh_tunnels[0].public_url)
|
180 |
-
else:
|
181 |
-
print('skip start ngrok')
|
182 |
-
|
183 |
from modules.shared_cmd_options import cmd_opts
|
184 |
|
185 |
if cmd_opts.nowebui:
|
|
|
2 |
|
3 |
import os
|
4 |
import time
|
5 |
+
import
|
6 |
|
7 |
from modules import timer
|
8 |
from modules import initialize_util
|
9 |
from modules import initialize
|
10 |
|
11 |
+
#ngrok穿透
|
12 |
+
ngrok_use = True
|
13 |
+
ngrokTokenFile='/root/main/Authtoken.txt' # 非必填 存放ngrokToken的文件的路径
|
14 |
+
|
15 |
+
def ngrok_start(ngrokTokenFile: str, port: int, address_name: str, should_run: bool):
|
16 |
+
if not should_run:
|
17 |
+
print('Skipping ngrok start')
|
18 |
+
return
|
19 |
+
if Path(ngrokTokenFile).exists():
|
20 |
+
with open(ngrokTokenFile, encoding="utf-8") as nkfile:
|
21 |
+
ngrokToken = nkfile.readline()
|
22 |
+
print('use nrgok')
|
23 |
+
from pyngrok import conf, ngrok
|
24 |
+
conf.get_default().auth_token = ngrokToken
|
25 |
+
conf.get_default().monitor_thread = False
|
26 |
+
ssh_tunnels = ngrok.get_tunnels(conf.get_default())
|
27 |
+
if len(ssh_tunnels) == 0:
|
28 |
+
ssh_tunnel = ngrok.connect(port, bind_tls=True)
|
29 |
+
print(f'{address_name}:' + ssh_tunnel.public_url)
|
30 |
+
else:
|
31 |
+
print(f'{address_name}:' + ssh_tunnels[0].public_url)
|
32 |
+
else:
|
33 |
+
print('skip start ngrok')
|
34 |
+
|
35 |
startup_timer = timer.startup_timer
|
36 |
startup_timer.record("launcher")
|
37 |
|
|
|
181 |
|
182 |
if __name__ == "__main__":
|
183 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
184 |
from modules.shared_cmd_options import cmd_opts
|
185 |
|
186 |
if cmd_opts.nowebui:
|