OsamaBinLikhon commited on
Commit
2af0649
Β·
verified Β·
1 Parent(s): 1e47f49

VS Code hybrid web interface

Browse files
Files changed (1) hide show
  1. app.py +220 -41
app.py CHANGED
@@ -1,15 +1,15 @@
1
  #!/usr/bin/env python3
2
  """
3
- Simple test application to demonstrate the antigravity package
4
- This will run a basic web interface to show the antigravity functionality
5
  """
6
 
7
  from http.server import HTTPServer, BaseHTTPRequestHandler
8
  import subprocess
9
  import sys
10
  import os
 
11
 
12
- class AntigravityHandler(BaseHTTPRequestHandler):
13
  def do_GET(self):
14
  if self.path == '/':
15
  self.send_response(200)
@@ -18,57 +18,222 @@ class AntigravityHandler(BaseHTTPRequestHandler):
18
 
19
  # Test antigravity package
20
  try:
21
- # Try to run antigravity command
22
- result = subprocess.run(['antigravity', '--help'],
23
  capture_output=True, text=True, timeout=5)
24
  antigravity_status = "Available" if result.returncode == 0 else "Error"
25
- antigravity_output = result.stdout if result.returncode == 0 else result.stderr
26
  except Exception as e:
27
  antigravity_status = "Error"
28
- antigravity_output = str(e)
29
 
30
  # System info
31
- system_info = subprocess.run(['uname', '-a'], capture_output=True, text=True)
 
 
 
 
32
 
33
  html = f"""
34
  <!DOCTYPE html>
35
  <html>
36
  <head>
37
- <title>Antigravity Docker Sandbox</title>
38
  <style>
39
- body {{ font-family: Arial, sans-serif; margin: 40px; background: #f0f0f0; }}
40
- .container {{ background: white; padding: 20px; border-radius: 8px; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }}
41
- .status {{ padding: 10px; margin: 10px 0; border-radius: 4px; }}
42
- .success {{ background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }}
43
- .error {{ background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }}
44
- pre {{ background: #f8f9fa; padding: 15px; border-radius: 4px; overflow-x: auto; }}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
  </style>
46
  </head>
47
  <body>
48
  <div class="container">
49
- <h1>πŸš€ Antigravity Docker Sandbox</h1>
50
- <p>This is a Docker-based Ubuntu environment with the antigravity package installed.</p>
51
-
52
- <h2>System Information</h2>
53
- <div class="status success">
54
- <strong>Platform:</strong> Ubuntu Docker Container<br>
55
- <strong>Python Version:</strong> {sys.version}<br>
56
- <strong>Working Directory:</strong> {os.getcwd()}
57
  </div>
58
 
59
- <h2>Antigravity Package Status</h2>
60
- <div class="status {'success' if antigravity_status == 'Available' else 'error'}">
61
- <strong>Status:</strong> {antigravity_status}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
62
  </div>
63
 
64
- <h3>Antigravity Command Output:</h3>
65
- <pre>{antigravity_output}</pre>
66
-
67
- <h3>System Details:</h3>
68
- <pre>{system_info.stdout}</pre>
69
-
70
- <p><em>Container is running on Hugging Face Spaces</em></p>
 
 
 
 
 
71
  </div>
 
 
 
 
 
 
72
  </body>
73
  </html>
74
  """
@@ -80,12 +245,25 @@ class AntigravityHandler(BaseHTTPRequestHandler):
80
  self.send_header('Content-type', 'application/json')
81
  self.end_headers()
82
 
83
- import json
84
  status_data = {
 
85
  'status': 'running',
86
  'antigravity_available': antigravity_status == 'Available',
87
- 'platform': 'Ubuntu Docker',
88
- 'python_version': sys.version
 
 
 
 
 
 
 
 
 
 
 
 
 
89
  }
90
  self.wfile.write(json.dumps(status_data).encode())
91
  else:
@@ -93,17 +271,18 @@ class AntigravityHandler(BaseHTTPRequestHandler):
93
  self.end_headers()
94
 
95
  def log_message(self, format, *args):
96
- print(f"[Server] {format % args}")
97
 
98
  def main():
99
  port = int(os.environ.get('PORT', 7860))
100
- server = HTTPServer(('0.0.0.0', port), AntigravityHandler)
101
- print(f"πŸš€ Antigravity Docker Sandbox running on port {port}")
102
- print(f"Access at: http://localhost:{port}")
 
103
  try:
104
  server.serve_forever()
105
  except KeyboardInterrupt:
106
- print("\nShutting down server...")
107
  server.shutdown()
108
 
109
  if __name__ == '__main__':
 
1
  #!/usr/bin/env python3
2
  """
3
+ Hybrid web interface for Antigravity - Status + VS Code Controls
 
4
  """
5
 
6
  from http.server import HTTPServer, BaseHTTPRequestHandler
7
  import subprocess
8
  import sys
9
  import os
10
+ import json
11
 
12
+ class AntigravityWebHandler(BaseHTTPRequestHandler):
13
  def do_GET(self):
14
  if self.path == '/':
15
  self.send_response(200)
 
18
 
19
  # Test antigravity package
20
  try:
21
+ result = subprocess.run(['antigravity', '--version'],
 
22
  capture_output=True, text=True, timeout=5)
23
  antigravity_status = "Available" if result.returncode == 0 else "Error"
24
+ antigravity_version = result.stdout.strip() if result.returncode == 0 else "Unable to determine"
25
  except Exception as e:
26
  antigravity_status = "Error"
27
+ antigravity_version = str(e)
28
 
29
  # System info
30
+ try:
31
+ system_info = subprocess.run(['uname', '-a'], capture_output=True, text=True)
32
+ system_details = system_info.stdout
33
+ except:
34
+ system_details = "System info unavailable"
35
 
36
  html = f"""
37
  <!DOCTYPE html>
38
  <html>
39
  <head>
40
+ <title>Antigravity VS Code Sandbox</title>
41
  <style>
42
+ body {{
43
+ font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
44
+ margin: 0;
45
+ padding: 20px;
46
+ background: linear-gradient(135deg, #007acc 0%, #1a1a1a 100%);
47
+ color: white;
48
+ min-height: 100vh;
49
+ }}
50
+ .container {{
51
+ background: rgba(255, 255, 255, 0.95);
52
+ color: #333;
53
+ padding: 30px;
54
+ border-radius: 15px;
55
+ box-shadow: 0 10px 30px rgba(0,0,0,0.3);
56
+ max-width: 1200px;
57
+ margin: 0 auto;
58
+ }}
59
+ .header {{
60
+ text-align: center;
61
+ margin-bottom: 30px;
62
+ padding-bottom: 20px;
63
+ border-bottom: 2px solid #007acc;
64
+ }}
65
+ .header h1 {{
66
+ color: #007acc;
67
+ margin: 0;
68
+ font-size: 2.5em;
69
+ }}
70
+ .vscode-badge {{
71
+ background: #007acc;
72
+ color: white;
73
+ padding: 8px 20px;
74
+ border-radius: 25px;
75
+ font-size: 0.9em;
76
+ display: inline-block;
77
+ margin: 10px 0;
78
+ font-weight: bold;
79
+ }}
80
+ .grid {{
81
+ display: grid;
82
+ grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
83
+ gap: 20px;
84
+ margin: 30px 0;
85
+ }}
86
+ .card {{
87
+ background: #f8f9fa;
88
+ padding: 25px;
89
+ border-radius: 12px;
90
+ border-left: 5px solid #007acc;
91
+ box-shadow: 0 4px 8px rgba(0,0,0,0.1);
92
+ }}
93
+ .card h3 {{
94
+ color: #007acc;
95
+ margin-top: 0;
96
+ font-size: 1.3em;
97
+ }}
98
+ .button {{
99
+ background: #007acc;
100
+ color: white;
101
+ padding: 12px 24px;
102
+ border: none;
103
+ border-radius: 8px;
104
+ font-size: 1em;
105
+ cursor: pointer;
106
+ text-decoration: none;
107
+ display: inline-block;
108
+ margin: 8px 8px 8px 0;
109
+ transition: background 0.3s;
110
+ }}
111
+ .button:hover {{
112
+ background: #005999;
113
+ }}
114
+ .button.green {{
115
+ background: #28a745;
116
+ }}
117
+ .button.green:hover {{
118
+ background: #1e7e34;
119
+ }}
120
+ .button.orange {{
121
+ background: #fd7e14;
122
+ }}
123
+ .button.orange:hover {{
124
+ background: #e55a00;
125
+ }}
126
+ .status {{
127
+ padding: 15px;
128
+ border-radius: 8px;
129
+ margin: 15px 0;
130
+ font-weight: bold;
131
+ }}
132
+ .success {{
133
+ background: #d4edda;
134
+ color: #155724;
135
+ border: 1px solid #c3e6cb;
136
+ }}
137
+ .warning {{
138
+ background: #fff3cd;
139
+ color: #856404;
140
+ border: 1px solid #ffeaa7;
141
+ }}
142
+ .pre {{
143
+ background: #2d3748;
144
+ color: #e2e8f0;
145
+ padding: 15px;
146
+ border-radius: 8px;
147
+ overflow-x: auto;
148
+ font-family: 'Courier New', monospace;
149
+ margin: 10px 0;
150
+ }}
151
+ .terminal {{
152
+ background: #1a1a1a;
153
+ color: #00ff00;
154
+ padding: 15px;
155
+ border-radius: 8px;
156
+ font-family: 'Courier New', monospace;
157
+ margin: 10px 0;
158
+ border: 2px solid #007acc;
159
+ }}
160
  </style>
161
  </head>
162
  <body>
163
  <div class="container">
164
+ <div class="header">
165
+ <h1>πŸš€ Antigravity VS Code Sandbox</h1>
166
+ <div class="vscode-badge">Full VS Code Environment</div>
167
+ <p>Docker-based development environment with complete VS Code functionality</p>
 
 
 
 
168
  </div>
169
 
170
+ <div class="grid">
171
+ <div class="card">
172
+ <h3>βœ… System Status</h3>
173
+ <div class="status {'success' if antigravity_status == 'Available' else 'warning'}">
174
+ Antigravity Package: {antigravity_status}
175
+ </div>
176
+ <div><strong>Version:</strong> {antigravity_version}</div>
177
+ <div><strong>Platform:</strong> Ubuntu Docker Container</div>
178
+ <div><strong>Python:</strong> {sys.version.split()[0]}</div>
179
+ <div><strong>Working Directory:</strong> {os.getcwd()}</div>
180
+ </div>
181
+
182
+ <div class="card">
183
+ <h3>🎯 Quick Actions</h3>
184
+ <p>Launch VS Code features instantly:</p>
185
+ <a href="#" onclick="runCommand('antigravity --serve-web')" class="button green">
186
+ 🌐 Start VS Code Web
187
+ </a>
188
+ <a href="#" onclick="runCommand('antigravity chat')" class="button orange">
189
+ πŸ€– AI Chat Assistant
190
+ </a>
191
+ <a href="#" onclick="runCommand('antigravity --version')" class="button">
192
+ ℹ️ Version Info
193
+ </a>
194
+ </div>
195
+
196
+ <div class="card">
197
+ <h3>πŸ› οΈ VS Code Features</h3>
198
+ <p>Available Antigravity commands:</p>
199
+ <div class="pre">antigravity --diff file1 file2
200
+ antigravity --merge base left right output
201
+ antigravity --new-window
202
+ antigravity --extensions-dir
203
+ antigravity --list-extensions
204
+ antigravity --install-extension ext-id
205
+ antigravity --serve-web
206
+ antigravity chat</div>
207
+ </div>
208
+
209
+ <div class="card">
210
+ <h3>πŸ“Š System Details</h3>
211
+ <div class="terminal">{system_details}</div>
212
+ <div style="margin-top: 15px; font-size: 0.9em; color: #666;">
213
+ <em>Container running on Hugging Face Spaces</em>
214
+ </div>
215
+ </div>
216
  </div>
217
 
218
+ <div class="card" style="margin-top: 20px;">
219
+ <h3>πŸš€ Development Environment Ready</h3>
220
+ <p>Your Antigravity Docker Space is fully configured with:</p>
221
+ <ul>
222
+ <li><strong>VS Code CLI:</strong> Full command-line interface</li>
223
+ <li><strong>File Management:</strong> Open, edit, compare, and merge files</li>
224
+ <li><strong>Extensions:</strong> Install and manage VS Code extensions</li>
225
+ <li><strong>Web Interface:</strong> Run VS Code in>
226
+ <li your browser</li><strong>AI Assistant:</strong> Built-in chat and coding help</li>
227
+ <li><strong>Development Tools:</strong> Complete development environment</li>
228
+ </ul>
229
+ </div>
230
  </div>
231
+
232
+ <script>
233
+ function runCommand(command) {{
234
+ alert('Command: ' + command + '\\n\\nThis would execute in the container terminal. Use the terminal tab in your space to run commands.');
235
+ }}
236
+ </script>
237
  </body>
238
  </html>
239
  """
 
245
  self.send_header('Content-type', 'application/json')
246
  self.end_headers()
247
 
 
248
  status_data = {
249
+ 'service': 'Antigravity VS Code Sandbox',
250
  'status': 'running',
251
  'antigravity_available': antigravity_status == 'Available',
252
+ 'features': [
253
+ 'VS Code CLI',
254
+ 'File Management',
255
+ 'Extensions',
256
+ 'Web Interface',
257
+ 'AI Assistant',
258
+ 'Development Tools'
259
+ ],
260
+ 'quick_commands': [
261
+ 'antigravity --serve-web',
262
+ 'antigravity chat',
263
+ 'antigravity --version',
264
+ 'antigravity --diff',
265
+ 'antigravity --list-extensions'
266
+ ]
267
  }
268
  self.wfile.write(json.dumps(status_data).encode())
269
  else:
 
271
  self.end_headers()
272
 
273
  def log_message(self, format, *args):
274
+ print(f"[Antigravity VS Code] {format % args}")
275
 
276
  def main():
277
  port = int(os.environ.get('PORT', 7860))
278
+ server = HTTPServer(('0.0.0.0', port), AntigravityWebHandler)
279
+ print(f"πŸš€ Antigravity VS Code Sandbox running on port {port}")
280
+ print(f"🌐 Access at: http://localhost:{port}")
281
+ print(f"πŸ“ VS Code features available via antigravity commands")
282
  try:
283
  server.serve_forever()
284
  except KeyboardInterrupt:
285
+ print("\nShutting down Antigravity VS Code Sandbox...")
286
  server.shutdown()
287
 
288
  if __name__ == '__main__':