triflix commited on
Commit
4313233
·
verified ·
1 Parent(s): 8e96920

Create templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +84 -0
templates/index.html ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>E2B VNC Sandbox</title>
7
+ <style>
8
+ body { font-family: 'Segoe UI', sans-serif; margin:0; padding:0; background:#f0f2f5; }
9
+ header { background:#333; color:#fff; padding:10px 20px; display:flex; justify-content:space-between; align-items:center; }
10
+ header h1 { margin:0; font-size:1.5em; }
11
+ button { margin:0 5px; padding:8px 12px; cursor:pointer; border:none; border-radius:4px; }
12
+ button:hover { opacity:0.8; }
13
+ .container { max-width:1200px; margin:auto; padding:20px; }
14
+ iframe { width:100%; height:500px; border:1px solid #ccc; border-radius:8px; margin-top:10px; }
15
+ input[type=text] { padding:10px; width:70%; border-radius:5px; border:1px solid #ccc; }
16
+ .status { margin-top:10px; font-weight:bold; }
17
+ .top-buttons { display:flex; gap:10px; }
18
+ .fullscreen { position:fixed; top:0; left:0; width:100%; height:100%; z-index:9999; background:#000; }
19
+ </style>
20
+ <script>
21
+ let isFullscreen = false;
22
+
23
+ function updateStatus(msg) {
24
+ document.getElementById('status').innerText = msg;
25
+ }
26
+
27
+ async function startVNC() {
28
+ const res = await fetch('/start', { method: 'POST' });
29
+ const data = await res.json();
30
+ document.getElementById('vnc_frame').src = data.iframe;
31
+ updateStatus(data.status);
32
+ }
33
+
34
+ async function stopVNC() {
35
+ const res = await fetch('/stop', { method: 'POST' });
36
+ const data = await res.json();
37
+ document.getElementById('vnc_frame').src = "";
38
+ updateStatus(data.status);
39
+ }
40
+
41
+ async function sendText() {
42
+ const teks = document.getElementById('vnc_input').value;
43
+ const form = new FormData();
44
+ form.append('teks', teks);
45
+ const res = await fetch('/send_text', { method: 'POST', body: form });
46
+ const data = await res.json();
47
+ document.getElementById('msg').innerText = data.msg;
48
+ document.getElementById('vnc_input').value = '';
49
+ }
50
+
51
+ function toggleFullscreen() {
52
+ const iframe = document.getElementById('vnc_frame');
53
+ if(!isFullscreen){
54
+ iframe.classList.add('fullscreen');
55
+ isFullscreen=true;
56
+ } else {
57
+ iframe.classList.remove('fullscreen');
58
+ isFullscreen=false;
59
+ }
60
+ }
61
+ </script>
62
+ </head>
63
+ <body>
64
+ <header>
65
+ <h1>E2B VNC Sandbox</h1>
66
+ <div class="top-buttons">
67
+ <button onclick="startVNC()">▶ Start</button>
68
+ <button onclick="stopVNC()">⏹ Stop</button>
69
+ <button onclick="toggleFullscreen()">⛶ Fullscreen</button>
70
+ </div>
71
+ </header>
72
+
73
+ <div class="container">
74
+ <iframe id="vnc_frame" src="{{ vnc_url }}"></iframe>
75
+ <div id="status" class="status">{{ status_msg }}</div>
76
+
77
+ <div style="margin-top:15px;">
78
+ <input type="text" id="vnc_input" placeholder="Type text to send">
79
+ <button onclick="sendText()">📤 Send</button>
80
+ <div id="msg" class="status"></div>
81
+ </div>
82
+ </div>
83
+ </body>
84
+ </html>