Thekingbalxd commited on
Commit
acdd15b
1 Parent(s): 8cd1ef6

Update webui (3) (1).py

Browse files
Files changed (1) hide show
  1. webui (3) (1).py +22 -0
webui (3) (1).py CHANGED
@@ -771,6 +771,28 @@ def dump_default_english_config():
771
 
772
 
773
  # dump_default_english_config()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
774
 
775
  shared.gradio_root.launch(
776
  inbrowser=args_manager.args.in_browser,
 
771
 
772
 
773
  # dump_default_english_config()
774
+ import subprocess
775
+ import threading
776
+ import time
777
+ import socket
778
+
779
+ def iframe_thread(port):
780
+ while True:
781
+ time.sleep(0.5)
782
+ sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
783
+ result = sock.connect_ex(('127.0.0.1', port))
784
+ if result == 0:
785
+ break
786
+ sock.close()
787
+ print("\nFooocus finished loading, trying to launch cloudflared (if it gets stuck here cloudflared is having issues)\n")
788
+ p = subprocess.Popen(["cloudflared", "tunnel", "--url", "http://127.0.0.1:{}".format(port)], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
789
+ for line in p.stderr:
790
+ l = line.decode()
791
+ if "trycloudflare.com" in l:
792
+ print("This is the URL to access Fooocus:", l[l.find("https"):], end='')
793
+
794
+ port = 7865 # Replace with the port number used by Fooocus
795
+ threading.Thread(target=iframe_thread, daemon=True, args=(port,)).start()
796
 
797
  shared.gradio_root.launch(
798
  inbrowser=args_manager.args.in_browser,