Upload 2 files
Browse files- app.py +8 -3
- requirements.txt +2 -2
app.py
CHANGED
|
@@ -15,14 +15,19 @@ def extract_host_port(url):
|
|
| 15 |
m = re.search(r"https?://([^/:]+)(?::(\d+))?", url)
|
| 16 |
if m:
|
| 17 |
host = m.group(1)
|
| 18 |
-
port = m.group(2) or "
|
| 19 |
return f"{host}:{port}"
|
| 20 |
return None
|
| 21 |
|
| 22 |
def start_vnc():
|
| 23 |
global desktop, vnc_url, vnc_host_port
|
| 24 |
if desktop is None:
|
| 25 |
-
desktop = Sandbox(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
desktop.stream.start(require_auth=False)
|
| 27 |
vnc_url = desktop.stream.get_url()
|
| 28 |
vnc_host_port = extract_host_port(vnc_url)
|
|
@@ -55,7 +60,7 @@ def kirim_teks(teks):
|
|
| 55 |
return "<p style='color:red;'>❌ VNC belum berjalan</p>"
|
| 56 |
try:
|
| 57 |
desktop.write(teks)
|
| 58 |
-
desktop.press("enter")
|
| 59 |
return f"<p style='color:green;'>✅ Teks '{teks}' berhasil dikirim</p>"
|
| 60 |
except Exception as ex:
|
| 61 |
return f"<p style='color:red;'>Error: {ex}</p>"
|
|
|
|
| 15 |
m = re.search(r"https?://([^/:]+)(?::(\d+))?", url)
|
| 16 |
if m:
|
| 17 |
host = m.group(1)
|
| 18 |
+
port = m.group(2) or "5900"
|
| 19 |
return f"{host}:{port}"
|
| 20 |
return None
|
| 21 |
|
| 22 |
def start_vnc():
|
| 23 |
global desktop, vnc_url, vnc_host_port
|
| 24 |
if desktop is None:
|
| 25 |
+
desktop = Sandbox.create(
|
| 26 |
+
template=None,
|
| 27 |
+
resolution=(1024, 768),
|
| 28 |
+
dpi=96,
|
| 29 |
+
allow_internet_access=True
|
| 30 |
+
)
|
| 31 |
desktop.stream.start(require_auth=False)
|
| 32 |
vnc_url = desktop.stream.get_url()
|
| 33 |
vnc_host_port = extract_host_port(vnc_url)
|
|
|
|
| 60 |
return "<p style='color:red;'>❌ VNC belum berjalan</p>"
|
| 61 |
try:
|
| 62 |
desktop.write(teks)
|
| 63 |
+
desktop.press("enter")
|
| 64 |
return f"<p style='color:green;'>✅ Teks '{teks}' berhasil dikirim</p>"
|
| 65 |
except Exception as ex:
|
| 66 |
return f"<p style='color:red;'>Error: {ex}</p>"
|
requirements.txt
CHANGED
|
@@ -1,2 +1,2 @@
|
|
| 1 |
-
|
| 2 |
-
|
|
|
|
| 1 |
+
gradio
|
| 2 |
+
e2b-desktop>=2.0.0
|