binary1ne commited on
Commit
031e219
·
verified ·
1 Parent(s): 55bc2f0

Update webui_with_vnc.py

Browse files
Files changed (1) hide show
  1. webui_with_vnc.py +14 -1
webui_with_vnc.py CHANGED
@@ -27,6 +27,18 @@ html="""
27
  }
28
  </script>
29
  """
 
 
 
 
 
 
 
 
 
 
 
 
30
 
31
  # # Example theme map for the argument parser (add more themes if you have them)
32
  # theme_map = {
@@ -104,7 +116,8 @@ def main():
104
  with gr.Tab("Web VNC"):
105
  # The iframe must point to the actual noVNC server (default: localhost:6080/vnc.html)
106
  # gr.HTML(f'<iframe src="http://localhost:6080/vnc.html" width="100%" height="800" style="border:1px solid red;"></iframe>')
107
- gr.HTML(html)
 
108
  demo.queue().launch(server_name=args.ip, server_port=args.port)
109
 
110
  if __name__ == "__main__":
 
27
  }
28
  </script>
29
  """
30
+ def get_vnc_iframe():
31
+ # get hostname + IP
32
+ hostname = socket.gethostname()
33
+ ip = socket.gethostbyname(hostname)
34
+
35
+ # build iframe URL
36
+ url = f"http://{ip}:6080/vnc.html?host={ip}&port=6080"
37
+ print("############## URL :",url)
38
+ # return HTML iframe
39
+ return f"""
40
+ <iframe src="{url}" width="100%" height="800" style="border:1px solid red;"></iframe>
41
+ """
42
 
43
  # # Example theme map for the argument parser (add more themes if you have them)
44
  # theme_map = {
 
116
  with gr.Tab("Web VNC"):
117
  # The iframe must point to the actual noVNC server (default: localhost:6080/vnc.html)
118
  # gr.HTML(f'<iframe src="http://localhost:6080/vnc.html" width="100%" height="800" style="border:1px solid red;"></iframe>')
119
+ # gr.HTML(html)
120
+ gr.HTML(get_vnc_iframe())
121
  demo.queue().launch(server_name=args.ip, server_port=args.port)
122
 
123
  if __name__ == "__main__":