Update webui.py
Browse files
webui.py
CHANGED
|
@@ -24,29 +24,6 @@ def create_api(app):
|
|
| 24 |
|
| 25 |
|
| 26 |
def api_only():
|
| 27 |
-
#ngrok穿透
|
| 28 |
-
ngrok_use = True
|
| 29 |
-
ngrokTokenFile='/root/main/Authtoken.txt' # 非必填 存放ngrokToken的文件的路径
|
| 30 |
-
|
| 31 |
-
def ngrok_start(ngrokTokenFile: str, port: int, address_name: str, should_run: bool):
|
| 32 |
-
if not should_run:
|
| 33 |
-
print('Skipping ngrok start')
|
| 34 |
-
return
|
| 35 |
-
if Path(ngrokTokenFile).exists():
|
| 36 |
-
with open(ngrokTokenFile, encoding="utf-8") as nkfile:
|
| 37 |
-
ngrokToken = nkfile.readline()
|
| 38 |
-
print('use nrgok')
|
| 39 |
-
from pyngrok import conf, ngrok
|
| 40 |
-
conf.get_default().auth_token = ngrokToken
|
| 41 |
-
conf.get_default().monitor_thread = False
|
| 42 |
-
ssh_tunnels = ngrok.get_tunnels(conf.get_default())
|
| 43 |
-
if len(ssh_tunnels) == 0:
|
| 44 |
-
ssh_tunnel = ngrok.connect(port, bind_tls=True)
|
| 45 |
-
print(f'{address_name}:' + ssh_tunnel.public_url)
|
| 46 |
-
else:
|
| 47 |
-
print(f'{address_name}:' + ssh_tunnels[0].public_url)
|
| 48 |
-
else:
|
| 49 |
-
print('skip start ngrok')
|
| 50 |
|
| 51 |
from fastapi import FastAPI
|
| 52 |
from modules.shared_cmd_options import cmd_opts
|
|
@@ -178,6 +155,31 @@ def webui():
|
|
| 178 |
|
| 179 |
|
| 180 |
if __name__ == "__main__":
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 181 |
from modules.shared_cmd_options import cmd_opts
|
| 182 |
|
| 183 |
if cmd_opts.nowebui:
|
|
|
|
| 24 |
|
| 25 |
|
| 26 |
def api_only():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
from fastapi import FastAPI
|
| 29 |
from modules.shared_cmd_options import cmd_opts
|
|
|
|
| 155 |
|
| 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:
|