Testaproxx99 commited on
Commit
acaa7a8
·
verified ·
1 Parent(s): 573bbf5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -5
app.py CHANGED
@@ -7,6 +7,15 @@ print("==================================================")
7
  print("🚀 Starting Cloudix Linux Desktop on Hugging Face")
8
  print("==================================================")
9
 
 
 
 
 
 
 
 
 
 
10
  os.environ["DISPLAY"] = ":1"
11
 
12
  # 1. Start Xvfb (Virtual Screen Display)
@@ -45,21 +54,17 @@ if os.path.exists(novnc_dir):
45
  else:
46
  os.makedirs(target_dir, exist_ok=True)
47
 
48
- # Create an index.html that auto-connects directly to the session
49
  vnc_html_path = os.path.join(target_dir, "vnc.html")
50
  index_html_path = os.path.join(target_dir, "index.html")
51
 
52
  if os.path.exists(vnc_html_path):
53
- # Copy vnc.html to index.html with autoconnect script
54
  with open(vnc_html_path, "r", encoding="utf-8") as f:
55
  content = f.read()
56
- # Inject autoconnect and resize parameters
57
  content = content.replace("<head>", '<head><script>if (!window.location.search) { window.location.search = "?autoconnect=true&resize=remote"; }</script>')
58
  with open(index_html_path, "w", encoding="utf-8") as f:
59
  f.write(content)
60
 
61
  print("[4/4] Starting WebSockify Gateway on port 7860...")
62
- # Start websockify binding on Hugging Face port 7860
63
  cmd = [
64
  "websockify",
65
  f"--web={target_dir}",
@@ -71,4 +76,4 @@ print("==================================================")
71
  print("✅ Cloudix Linux Desktop Ready on Port 7860!")
72
  print("==================================================")
73
 
74
- subprocess.run(cmd)
 
7
  print("🚀 Starting Cloudix Linux Desktop on Hugging Face")
8
  print("==================================================")
9
 
10
+ # ZeroGPU initialization
11
+ try:
12
+ import spaces
13
+ @spaces.GPU
14
+ def gpu_init():
15
+ return "GPU ready"
16
+ except Exception as e:
17
+ pass
18
+
19
  os.environ["DISPLAY"] = ":1"
20
 
21
  # 1. Start Xvfb (Virtual Screen Display)
 
54
  else:
55
  os.makedirs(target_dir, exist_ok=True)
56
 
 
57
  vnc_html_path = os.path.join(target_dir, "vnc.html")
58
  index_html_path = os.path.join(target_dir, "index.html")
59
 
60
  if os.path.exists(vnc_html_path):
 
61
  with open(vnc_html_path, "r", encoding="utf-8") as f:
62
  content = f.read()
 
63
  content = content.replace("<head>", '<head><script>if (!window.location.search) { window.location.search = "?autoconnect=true&resize=remote"; }</script>')
64
  with open(index_html_path, "w", encoding="utf-8") as f:
65
  f.write(content)
66
 
67
  print("[4/4] Starting WebSockify Gateway on port 7860...")
 
68
  cmd = [
69
  "websockify",
70
  f"--web={target_dir}",
 
76
  print("✅ Cloudix Linux Desktop Ready on Port 7860!")
77
  print("==================================================")
78
 
79
+ subprocess.run(cmd)