binary1ne commited on
Commit
55bc2f0
·
verified ·
1 Parent(s): 8f5a433

Update webui_with_vnc.py

Browse files
Files changed (1) hide show
  1. webui_with_vnc.py +16 -5
webui_with_vnc.py CHANGED
@@ -6,14 +6,25 @@ import gradio as gr
6
  from src.webui.interface import theme_map, create_ui
7
 
8
  html="""
9
- <div id="vnc-container" style="width:100%;height:800px;border:1px solid #ccc"></div>
10
  <script type="module">
11
  import RFB from "https://unpkg.com/@novnc/novnc/core/rfb.js";
12
 
13
- const rfb = new RFB(document.getElementById('vnc-container'),
14
- "ws://localhost:6080/websockify");
15
- rfb.scaleViewport = true;
16
- rfb.background = 'black';
 
 
 
 
 
 
 
 
 
 
 
17
  </script>
18
  """
19
 
 
6
  from src.webui.interface import theme_map, create_ui
7
 
8
  html="""
9
+ <div id="vnc-container" style="width:100%;height:800px;border:2px solid #444;border-radius:8px;"></div>
10
  <script type="module">
11
  import RFB from "https://unpkg.com/@novnc/novnc/core/rfb.js";
12
 
13
+ // Connect directly to your WebSocket proxy
14
+ const url = "ws://localhost:6080/websockify";
15
+ const target = document.getElementById('vnc-container');
16
+
17
+ try {
18
+ const rfb = new RFB(target, url);
19
+ rfb.viewOnly = false; // true = disable keyboard/mouse input
20
+ rfb.scaleViewport = true;
21
+ rfb.resizeSession = true;
22
+ rfb.background = "black";
23
+
24
+ console.log("✅ Connected to VNC via WebSocket:", url);
25
+ } catch (err) {
26
+ target.innerHTML = "<p style='color:red'> ❌ Failed to connect to VNC server.<br>" + err + "</p>";
27
+ }
28
  </script>
29
  """
30