theguywhosucks commited on
Commit
0e92a82
Β·
verified Β·
1 Parent(s): aba9687

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +401 -232
app.py CHANGED
@@ -45,7 +45,7 @@ class SandboxManager:
45
  requirements=requirements_txt,
46
  api_name="/launch_sandbox"
47
  )
48
- return f"πŸš€ Sandbox launched successfully on {self.current_engine}!\n\nResponse: {result}", self.get_status()
49
  except Exception as e:
50
  return f"❌ Launch failed: {str(e)}", ""
51
 
@@ -56,9 +56,9 @@ class SandboxManager:
56
  try:
57
  result = self.client.predict(api_name="/fetch_logs")
58
  timestamp = datetime.now().strftime("%H:%M:%S")
59
- return f"πŸ“‹ Logs fetched at {timestamp} from {self.current_engine}:\n\n{result}"
60
  except Exception as e:
61
- return f"❌ Failed to fetch logs: {str(e)}"
62
 
63
  def kill_sandbox(self):
64
  if not self.is_connected:
@@ -66,7 +66,7 @@ class SandboxManager:
66
 
67
  try:
68
  result = self.client.predict(api_name="/kill_sandbox")
69
- return f"πŸ›‘ Sandbox terminated on {self.current_engine}\n\nResponse: {result}", self.get_status()
70
  except Exception as e:
71
  return f"❌ Kill failed: {str(e)}", ""
72
 
@@ -87,186 +87,317 @@ sandbox = SandboxManager()
87
  # Sample code templates
88
  SAMPLE_MAIN_PY = """#!/usr/bin/env python3
89
  \"\"\"
90
- Welcome to Sandbox Cloud IDE
91
- Write your Python code here
92
  \"\"\"
93
 
94
  import os
95
  import sys
 
96
  from datetime import datetime
97
 
98
  def main():
99
- print("πŸš€ Sandbox Environment Started!")
100
- print(f"⏰ Current time: {datetime.now()}")
101
- print(f"🐍 Python version: {sys.version}")
102
- print(f"πŸ“ Working directory: {os.getcwd()}")
 
 
 
 
 
 
 
 
 
 
103
 
104
- # Your code here
105
- print("\\n✨ Hello from the cloud sandbox! ✨")
106
 
107
- # Example: Simple calculation
108
- numbers = [1, 2, 3, 4, 5]
109
- result = sum(numbers)
110
- print(f"πŸ“Š Sum of {numbers} = {result}")
111
 
112
  if __name__ == "__main__":
113
  main()
114
  """
115
 
116
- SAMPLE_REQUIREMENTS_TXT = """# Python package dependencies
117
- # Add one package per line
 
 
 
 
 
 
 
 
 
118
 
119
- # Data science libraries
120
- numpy>=1.21.0
121
- pandas>=1.3.0
122
 
123
  # Web frameworks
124
- # flask>=2.0.0
125
- # fastapi>=0.68.0
 
126
 
127
- # Machine learning
128
- # scikit-learn>=1.0.0
129
- # tensorflow>=2.6.0
130
 
131
- # Utilities
132
- requests>=2.25.0
133
- python-dateutil>=2.8.0
134
 
135
- # Add your packages here...
 
 
136
  """
137
 
138
- # Custom CSS for modern IDE styling
139
- custom_css = """
 
 
140
  .gradio-container {
141
- font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
142
- background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
 
143
  min-height: 100vh;
 
 
144
  }
145
 
146
- .ide-container {
147
- background: rgba(255, 255, 255, 0.98);
148
- backdrop-filter: blur(20px);
149
- border-radius: 20px;
150
- padding: 25px;
151
- margin: 20px;
152
- box-shadow: 0 25px 50px rgba(0, 0, 0, 0.15);
 
 
153
  }
154
 
155
- .engine-display {
156
- background: linear-gradient(135deg, #00c6ff 0%, #0072ff 100%);
157
- color: white;
158
- padding: 15px;
159
- border-radius: 12px;
160
- text-align: center;
161
- font-weight: 600;
162
- margin: 10px 0;
163
- font-family: 'JetBrains Mono', monospace;
164
- box-shadow: 0 8px 20px rgba(0, 114, 255, 0.3);
165
  }
166
 
167
- .status-card {
168
- background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
169
- color: white;
170
- padding: 18px;
171
- border-radius: 15px;
172
- margin: 10px 0;
173
- font-weight: 600;
174
- text-align: center;
175
- box-shadow: 0 10px 25px rgba(102, 126, 234, 0.4);
176
  }
177
 
178
- .code-editor {
179
- border-radius: 12px !important;
180
- border: 2px solid #e1e8ed !important;
181
- font-family: 'JetBrains Mono', 'Fira Code', 'SF Mono', monospace !important;
182
- background: #1e1e1e !important;
183
- box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1) !important;
 
184
  }
185
 
186
- .requirements-editor {
187
- border-radius: 12px !important;
188
- border: 2px solid #e1e8ed !important;
189
- font-family: 'JetBrains Mono', 'Fira Code', 'SF Mono', monospace !important;
190
- background: #282828 !important;
191
- box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1) !important;
 
 
192
  }
193
 
194
- .action-button {
195
- background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%) !important;
196
- border: none !important;
197
- border-radius: 12px !important;
198
- padding: 14px 28px !important;
 
199
  color: white !important;
200
- font-weight: 600 !important;
201
- transition: all 0.3s ease !important;
202
- box-shadow: 0 6px 18px rgba(79, 172, 254, 0.4) !important;
203
- font-size: 15px !important;
 
 
 
 
 
 
 
 
204
  }
205
 
206
- .action-button:hover {
207
- transform: translateY(-3px) !important;
208
- box-shadow: 0 12px 30px rgba(79, 172, 254, 0.6) !important;
 
 
 
 
 
 
 
209
  }
210
 
211
- .stop-button {
212
- background: linear-gradient(135deg, #ff6b6b 0%, #ee5a52 100%) !important;
213
- box-shadow: 0 6px 18px rgba(255, 107, 107, 0.4) !important;
 
 
 
 
 
 
 
 
 
 
 
214
  }
215
 
216
- .stop-button:hover {
217
- box-shadow: 0 12px 30px rgba(255, 107, 107, 0.6) !important;
218
  }
219
 
220
- .logs-output {
221
- background: #0d1117 !important;
222
- color: #c9d1d9 !important;
223
- border-radius: 12px !important;
224
- font-family: 'JetBrains Mono', 'Fira Code', monospace !important;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
225
  font-size: 13px !important;
226
- line-height: 1.6 !important;
227
- border: 1px solid #30363d !important;
228
- box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.3) !important;
229
  }
230
 
231
- .header-title {
232
- background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
233
- -webkit-background-clip: text;
234
- -webkit-text-fill-color: transparent;
235
- background-clip: text;
236
- font-size: 3rem;
237
- font-weight: 900;
238
- text-align: center;
239
- margin-bottom: 10px;
240
- text-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
 
 
 
 
 
 
 
 
 
 
241
  }
242
 
243
- .header-subtitle {
244
- text-align: center;
245
- color: rgba(255, 255, 255, 0.8);
246
- font-size: 1.2rem;
247
- margin-bottom: 40px;
248
- font-weight: 300;
249
  }
250
 
251
- .ide-tabs {
252
- border-radius: 15px;
253
- overflow: hidden;
254
- box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
 
 
 
 
255
  }
256
 
257
- .file-icon {
258
- font-size: 1.2em;
259
- margin-right: 8px;
260
  }
261
 
262
- .section-header {
263
- background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
264
- -webkit-background-clip: text;
265
- -webkit-text-fill-color: transparent;
266
- background-clip: text;
267
- font-weight: 700;
268
- font-size: 1.3rem;
269
- margin: 20px 0 15px 0;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
270
  }
271
  """
272
 
@@ -280,116 +411,156 @@ def load_sample_files():
280
  """Load sample files into the editors"""
281
  return SAMPLE_MAIN_PY, SAMPLE_REQUIREMENTS_TXT
282
 
283
- # Build the IDE interface
284
- with gr.Blocks(css=custom_css, title="Sandbox Cloud IDE", theme=gr.themes.Soft()) as demo:
 
 
285
  gr.HTML("""
286
- <div class="header-title">☁️ Sandbox Cloud IDE</div>
287
- <div class="header-subtitle">Professional cloud development environment with dual-engine support</div>
 
 
 
 
 
 
 
 
288
  """)
289
 
 
 
 
290
  with gr.Row():
 
291
  with gr.Column(scale=3):
292
- # Engine & Connection Section
293
- with gr.Group(elem_classes=["ide-container"]):
294
- gr.HTML('<div class="section-header">πŸ”Œ Engine Connection</div>')
295
-
296
- with gr.Row():
297
- connect_btn = gr.Button("πŸ”„ Connect to Random Engine", variant="primary", elem_classes=["action-button"])
298
- load_samples_btn = gr.Button("πŸ“„ Load Sample Files", elem_classes=["action-button"])
299
-
300
- current_engine_display = gr.Textbox(
301
- value="No engine selected",
302
- label="Current Engine",
303
- interactive=False,
304
- elem_classes=["engine-display"]
305
- )
306
-
307
- connection_status = gr.Textbox(
308
- value="πŸ”΄ Not connected",
309
- label="Connection Status",
310
- interactive=False,
311
- elem_classes=["status-card"]
312
- )
313
 
314
- # IDE Section
315
- with gr.Group(elem_classes=["ide-container"]):
316
- gr.HTML('<div class="section-header">πŸ’» Cloud IDE</div>')
317
-
318
- with gr.Tab("πŸ“„ main.py"):
319
- main_py_editor = gr.Code(
320
- value="# Write your Python code here\nprint('Hello, Sandbox Cloud!')",
321
- label="main.py",
322
- language="python",
323
- lines=20,
324
- elem_classes=["code-editor"],
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
325
  show_label=False
326
  )
327
-
328
- with gr.Tab("πŸ“¦ requirements.txt"):
329
- requirements_editor = gr.Textbox(
330
- value="# Add your Python package dependencies here\n# One package per line\n",
331
- label="requirements.txt",
332
- lines=20,
333
- elem_classes=["requirements-editor"],
334
- show_label=False,
335
- max_lines=20
336
- )
337
-
338
- # Control Buttons
339
- with gr.Row():
340
- launch_btn = gr.Button("πŸš€ Deploy & Run", variant="primary", elem_classes=["action-button"], size="lg")
341
- kill_btn = gr.Button("πŸ›‘ Stop Sandbox", elem_classes=["action-button", "stop-button"], size="lg")
342
-
343
- # Launch Output
344
- launch_output = gr.Textbox(
345
- label="Deployment Output",
346
- lines=6,
347
- interactive=False,
348
- placeholder="Deployment status will appear here...",
349
- elem_classes=["logs-output"]
350
- )
351
 
 
352
  with gr.Column(scale=1):
353
- # Status Monitor
354
- with gr.Group(elem_classes=["ide-container"]):
355
- gr.HTML('<div class="section-header">πŸ“Š Status Monitor</div>')
356
-
357
- status_display = gr.Textbox(
358
- value="πŸ”΄ Disconnected",
359
- label="Sandbox Status",
360
- interactive=False,
361
- elem_classes=["status-card"]
362
- )
363
-
364
- status_refresh_btn = gr.Button("πŸ”„ Refresh", elem_classes=["action-button"])
365
-
366
- # Auto-refresh Settings
367
- gr.Markdown("#### βš™οΈ Auto-Refresh")
368
- auto_refresh_status_cb = gr.Checkbox(
369
- label="Status (5s)",
370
- value=False
371
- )
372
- auto_refresh_logs_cb = gr.Checkbox(
373
- label="Logs (10s)",
374
- value=False
375
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
376
 
377
- # System Logs Section
378
- with gr.Group(elem_classes=["ide-container"]):
379
- gr.HTML('<div class="section-header">πŸ“‹ System Logs</div>')
380
-
381
- with gr.Row():
382
- fetch_logs_btn = gr.Button("πŸ“‹ Fetch Latest Logs", elem_classes=["action-button"])
383
- gr.HTML('<div style="flex-grow: 1;"></div>') # Spacer
384
-
385
- logs_display = gr.Textbox(
386
- label="System Logs",
387
- lines=15,
388
- interactive=False,
389
- elem_classes=["logs-output"],
390
- placeholder="πŸ“‹ System logs will appear here...\n\nClick 'Fetch Latest Logs' to view output from your running code.",
391
- show_label=False
392
- )
393
 
394
  # Event Handlers
395
  connect_btn.click(
@@ -454,11 +625,9 @@ with gr.Blocks(css=custom_css, title="Sandbox Cloud IDE", theme=gr.themes.Soft()
454
 
455
  # Footer
456
  gr.HTML("""
457
- <div style="text-align: center; margin-top: 50px; color: rgba(255,255,255,0.7); font-size: 0.95rem;">
458
- <p>☁️ Sandbox Cloud Service β€’ Dual-Engine Architecture β€’ Built with ❀️ by ChocoLaboratory</p>
459
- <p style="font-size: 0.8rem; margin-top: 10px;">
460
- Available Engines: SANDBOXBACKEND1, SANDBOXBACKEND2
461
- </p>
462
  </div>
463
  """)
464
 
 
45
  requirements=requirements_txt,
46
  api_name="/launch_sandbox"
47
  )
48
+ return f"βœ… Sandbox launched successfully on {self.current_engine}!\n\nResponse: {result}", self.get_status()
49
  except Exception as e:
50
  return f"❌ Launch failed: {str(e)}", ""
51
 
 
56
  try:
57
  result = self.client.predict(api_name="/fetch_logs")
58
  timestamp = datetime.now().strftime("%H:%M:%S")
59
+ return f"Logs fetched at {timestamp} from {self.current_engine}:\n\n{result}"
60
  except Exception as e:
61
+ return f"Failed to fetch logs: {str(e)}"
62
 
63
  def kill_sandbox(self):
64
  if not self.is_connected:
 
66
 
67
  try:
68
  result = self.client.predict(api_name="/kill_sandbox")
69
+ return f"βœ… Sandbox terminated on {self.current_engine}\n\nResponse: {result}", self.get_status()
70
  except Exception as e:
71
  return f"❌ Kill failed: {str(e)}", ""
72
 
 
87
  # Sample code templates
88
  SAMPLE_MAIN_PY = """#!/usr/bin/env python3
89
  \"\"\"
90
+ AWS Sandbox Environment
91
+ Python Application Template
92
  \"\"\"
93
 
94
  import os
95
  import sys
96
+ import json
97
  from datetime import datetime
98
 
99
  def main():
100
+ print("AWS Sandbox Environment - Python Runtime")
101
+ print("=" * 50)
102
+ print(f"Timestamp: {datetime.now().isoformat()}")
103
+ print(f"Python Version: {sys.version}")
104
+ print(f"Working Directory: {os.getcwd()}")
105
+ print("=" * 50)
106
+
107
+ # Application logic here
108
+ data = {
109
+ "service": "aws-sandbox",
110
+ "status": "running",
111
+ "timestamp": datetime.now().isoformat(),
112
+ "environment": "production"
113
+ }
114
 
115
+ print("Application Output:")
116
+ print(json.dumps(data, indent=2))
117
 
118
+ # Example computation
119
+ numbers = list(range(1, 11))
120
+ result = sum(x**2 for x in numbers)
121
+ print(f"\\nComputation Result: Sum of squares 1-10 = {result}")
122
 
123
  if __name__ == "__main__":
124
  main()
125
  """
126
 
127
+ SAMPLE_REQUIREMENTS_TXT = """# AWS Sandbox - Python Dependencies
128
+ # Production-ready package versions
129
+
130
+ # Core utilities
131
+ requests==2.31.0
132
+ python-dateutil==2.8.2
133
+ pytz==2023.3
134
+
135
+ # Data processing
136
+ numpy==1.24.3
137
+ pandas==2.0.3
138
 
139
+ # AWS SDK (if needed)
140
+ # boto3==1.28.25
141
+ # botocore==1.31.25
142
 
143
  # Web frameworks
144
+ # flask==2.3.2
145
+ # fastapi==0.100.0
146
+ # uvicorn==0.23.1
147
 
148
+ # Database drivers
149
+ # psycopg2-binary==2.9.7
150
+ # pymongo==4.4.1
151
 
152
+ # Scientific computing
153
+ # scipy==1.11.1
154
+ # scikit-learn==1.3.0
155
 
156
+ # Development tools
157
+ # pytest==7.4.0
158
+ # black==23.7.0
159
  """
160
 
161
+ # AWS-style CSS
162
+ aws_css = """
163
+ @import url('https://fonts.googleapis.com/css2?family=Amazon+Ember:wght@300;400;500;600;700&display=swap');
164
+
165
  .gradio-container {
166
+ font-family: 'Amazon Ember', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif !important;
167
+ background-color: #f2f3f3 !important;
168
+ color: #232f3e !important;
169
  min-height: 100vh;
170
+ margin: 0;
171
+ padding: 0;
172
  }
173
 
174
+ /* AWS Header */
175
+ .aws-header {
176
+ background-color: #232f3e !important;
177
+ color: white !important;
178
+ padding: 12px 20px !important;
179
+ margin: 0 !important;
180
+ border-bottom: 1px solid #3c4043 !important;
181
+ font-size: 14px !important;
182
+ font-weight: 500 !important;
183
  }
184
 
185
+ .aws-nav {
186
+ background-color: #37475a !important;
187
+ color: #ffffff !important;
188
+ padding: 8px 20px !important;
189
+ font-size: 13px !important;
190
+ border-bottom: 1px solid #485563 !important;
 
 
 
 
191
  }
192
 
193
+ .aws-service-title {
194
+ font-size: 20px !important;
195
+ font-weight: 500 !important;
196
+ color: #232f3e !important;
197
+ margin: 20px 0 10px 0 !important;
 
 
 
 
198
  }
199
 
200
+ .aws-container {
201
+ background-color: white !important;
202
+ border: 1px solid #d5dbdb !important;
203
+ border-radius: 8px !important;
204
+ margin: 16px !important;
205
+ padding: 0 !important;
206
+ box-shadow: 0 1px 3px rgba(0,0,0,0.1) !important;
207
  }
208
 
209
+ .aws-container-header {
210
+ background-color: #fafbfc !important;
211
+ border-bottom: 1px solid #d5dbdb !important;
212
+ padding: 16px 20px !important;
213
+ font-weight: 500 !important;
214
+ color: #232f3e !important;
215
+ font-size: 16px !important;
216
+ border-radius: 8px 8px 0 0 !important;
217
  }
218
 
219
+ .aws-container-content {
220
+ padding: 20px !important;
221
+ }
222
+
223
+ .aws-button-primary {
224
+ background-color: #ec7211 !important;
225
  color: white !important;
226
+ border: 1px solid #ec7211 !important;
227
+ border-radius: 4px !important;
228
+ padding: 8px 16px !important;
229
+ font-size: 14px !important;
230
+ font-weight: 500 !important;
231
+ cursor: pointer !important;
232
+ transition: all 0.2s ease !important;
233
+ }
234
+
235
+ .aws-button-primary:hover {
236
+ background-color: #d86613 !important;
237
+ border-color: #d86613 !important;
238
  }
239
 
240
+ .aws-button-secondary {
241
+ background-color: white !important;
242
+ color: #232f3e !important;
243
+ border: 1px solid #d5dbdb !important;
244
+ border-radius: 4px !important;
245
+ padding: 8px 16px !important;
246
+ font-size: 14px !important;
247
+ font-weight: 500 !important;
248
+ cursor: pointer !important;
249
+ transition: all 0.2s ease !important;
250
  }
251
 
252
+ .aws-button-secondary:hover {
253
+ background-color: #f2f3f3 !important;
254
+ border-color: #879596 !important;
255
+ }
256
+
257
+ .aws-button-danger {
258
+ background-color: #d13212 !important;
259
+ color: white !important;
260
+ border: 1px solid #d13212 !important;
261
+ border-radius: 4px !important;
262
+ padding: 8px 16px !important;
263
+ font-size: 14px !important;
264
+ font-weight: 500 !important;
265
+ cursor: pointer !important;
266
  }
267
 
268
+ .aws-button-danger:hover {
269
+ background-color: #b02e0c !important;
270
  }
271
 
272
+ .aws-status-success {
273
+ color: #1d8102 !important;
274
+ background-color: #e6f3e6 !important;
275
+ border: 1px solid #7aa116 !important;
276
+ border-radius: 4px !important;
277
+ padding: 12px 16px !important;
278
+ font-size: 14px !important;
279
+ font-weight: 500 !important;
280
+ }
281
+
282
+ .aws-status-error {
283
+ color: #d13212 !important;
284
+ background-color: #fdf2f2 !important;
285
+ border: 1px solid #d13212 !important;
286
+ border-radius: 4px !important;
287
+ padding: 12px 16px !important;
288
+ font-size: 14px !important;
289
+ font-weight: 500 !important;
290
+ }
291
+
292
+ .aws-status-warning {
293
+ color: #b7911a !important;
294
+ background-color: #fffbf0 !important;
295
+ border: 1px solid #b7911a !important;
296
+ border-radius: 4px !important;
297
+ padding: 12px 16px !important;
298
+ font-size: 14px !important;
299
+ font-weight: 500 !important;
300
+ }
301
+
302
+ .aws-code-editor {
303
+ font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace !important;
304
+ background-color: #1e1e1e !important;
305
+ border: 1px solid #d5dbdb !important;
306
+ border-radius: 4px !important;
307
  font-size: 13px !important;
 
 
 
308
  }
309
 
310
+ .aws-logs {
311
+ font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace !important;
312
+ background-color: #232f3e !important;
313
+ color: #ffffff !important;
314
+ border: 1px solid #d5dbdb !important;
315
+ border-radius: 4px !important;
316
+ font-size: 12px !important;
317
+ line-height: 1.4 !important;
318
+ }
319
+
320
+ .aws-form-group {
321
+ margin-bottom: 16px !important;
322
+ }
323
+
324
+ .aws-form-label {
325
+ font-size: 14px !important;
326
+ font-weight: 500 !important;
327
+ color: #232f3e !important;
328
+ margin-bottom: 4px !important;
329
+ display: block !important;
330
  }
331
 
332
+ .aws-sidebar {
333
+ background-color: white !important;
334
+ border: 1px solid #d5dbdb !important;
335
+ border-radius: 8px !important;
336
+ padding: 0 !important;
337
+ height: fit-content !important;
338
  }
339
 
340
+ .aws-sidebar-header {
341
+ background-color: #fafbfc !important;
342
+ border-bottom: 1px solid #d5dbdb !important;
343
+ padding: 12px 16px !important;
344
+ font-weight: 500 !important;
345
+ color: #232f3e !important;
346
+ font-size: 14px !important;
347
+ border-radius: 8px 8px 0 0 !important;
348
  }
349
 
350
+ .aws-sidebar-content {
351
+ padding: 16px !important;
 
352
  }
353
 
354
+ .aws-info-box {
355
+ background-color: #f0f8ff !important;
356
+ border: 1px solid #4a90e2 !important;
357
+ border-radius: 4px !important;
358
+ padding: 12px !important;
359
+ margin: 8px 0 !important;
360
+ font-size: 13px !important;
361
+ color: #232f3e !important;
362
+ }
363
+
364
+ .aws-breadcrumb {
365
+ font-size: 12px !important;
366
+ color: #687078 !important;
367
+ margin: 8px 20px !important;
368
+ }
369
+
370
+ .aws-tabs {
371
+ border: 1px solid #d5dbdb !important;
372
+ border-radius: 8px !important;
373
+ background-color: white !important;
374
+ overflow: hidden !important;
375
+ }
376
+
377
+ .aws-tab-content {
378
+ padding: 16px !important;
379
+ }
380
+
381
+ .aws-metric {
382
+ text-align: center !important;
383
+ padding: 12px !important;
384
+ border-right: 1px solid #d5dbdb !important;
385
+ }
386
+
387
+ .aws-metric:last-child {
388
+ border-right: none !important;
389
+ }
390
+
391
+ .aws-metric-value {
392
+ font-size: 24px !important;
393
+ font-weight: 600 !important;
394
+ color: #232f3e !important;
395
+ }
396
+
397
+ .aws-metric-label {
398
+ font-size: 12px !important;
399
+ color: #687078 !important;
400
+ margin-top: 4px !important;
401
  }
402
  """
403
 
 
411
  """Load sample files into the editors"""
412
  return SAMPLE_MAIN_PY, SAMPLE_REQUIREMENTS_TXT
413
 
414
+ # Build the AWS-style interface
415
+ with gr.Blocks(css=aws_css, title="AWS Sandbox Service", theme=gr.themes.Default()) as demo:
416
+
417
+ # AWS Header
418
  gr.HTML("""
419
+ <div class="aws-header">
420
+ <span>πŸ”Ά Amazon Web Services</span>
421
+ <span style="float: right;">Sandbox Compute Service</span>
422
+ </div>
423
+ <div class="aws-nav">
424
+ Services > Compute > Sandbox > Management Console
425
+ </div>
426
+ <div class="aws-breadcrumb">
427
+ Home > Sandbox Service > Console
428
+ </div>
429
  """)
430
 
431
+ # Service Title
432
+ gr.HTML('<div class="aws-service-title">Sandbox Compute Service</div>')
433
+
434
  with gr.Row():
435
+ # Main Content Area
436
  with gr.Column(scale=3):
437
+ # Connection Management
438
+ with gr.Group(elem_classes=["aws-container"]):
439
+ gr.HTML('<div class="aws-container-header">πŸ”— Engine Connection</div>')
440
+ with gr.Group(elem_classes=["aws-container-content"]):
441
+ with gr.Row():
442
+ connect_btn = gr.Button("Connect to Engine", elem_classes=["aws-button-primary"])
443
+ load_samples_btn = gr.Button("Load Sample Code", elem_classes=["aws-button-secondary"])
444
+
445
+ current_engine_display = gr.Textbox(
446
+ value="No engine selected",
447
+ label="Active Compute Engine",
448
+ interactive=False,
449
+ elem_classes=["aws-info-box"]
450
+ )
451
+
452
+ connection_status = gr.Textbox(
453
+ value="Disconnected",
454
+ label="Connection Status",
455
+ interactive=False,
456
+ elem_classes=["aws-status-error"]
457
+ )
458
 
459
+ # Code Development Environment
460
+ with gr.Group(elem_classes=["aws-container"]):
461
+ gr.HTML('<div class="aws-container-header">πŸ’» Development Environment</div>')
462
+ with gr.Group(elem_classes=["aws-container-content"]):
463
+ with gr.Tab("main.py", elem_classes=["aws-tabs"]):
464
+ with gr.Group(elem_classes=["aws-tab-content"]):
465
+ gr.HTML('<div class="aws-form-label">πŸ“„ Application Code (main.py)</div>')
466
+ main_py_editor = gr.Code(
467
+ value="# AWS Sandbox Python Application\nprint('Hello from AWS Sandbox!')",
468
+ language="python",
469
+ lines=18,
470
+ elem_classes=["aws-code-editor"],
471
+ show_label=False
472
+ )
473
+
474
+ with gr.Tab("requirements.txt", elem_classes=["aws-tabs"]):
475
+ with gr.Group(elem_classes=["aws-tab-content"]):
476
+ gr.HTML('<div class="aws-form-label">πŸ“¦ Dependencies (requirements.txt)</div>')
477
+ requirements_editor = gr.Textbox(
478
+ value="# Add Python package dependencies\n# Example: requests>=2.25.0",
479
+ lines=18,
480
+ elem_classes=["aws-code-editor"],
481
+ show_label=False,
482
+ max_lines=25
483
+ )
484
+
485
+ # Deployment Actions
486
+ gr.HTML('<div style="margin-top: 16px;"></div>')
487
+ with gr.Row():
488
+ launch_btn = gr.Button("Deploy Application", elem_classes=["aws-button-primary"], size="lg")
489
+ kill_btn = gr.Button("Terminate Instance", elem_classes=["aws-button-danger"], size="lg")
490
+
491
+ # Deployment Output
492
+ gr.HTML('<div class="aws-form-label" style="margin-top: 16px;">Deployment Status</div>')
493
+ launch_output = gr.Textbox(
494
+ lines=6,
495
+ interactive=False,
496
+ placeholder="Deployment status and output will appear here...",
497
+ elem_classes=["aws-logs"],
498
  show_label=False
499
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
500
 
501
+ # Sidebar
502
  with gr.Column(scale=1):
503
+ # Instance Status
504
+ with gr.Group(elem_classes=["aws-sidebar"]):
505
+ gr.HTML('<div class="aws-sidebar-header">πŸ“Š Instance Status</div>')
506
+ with gr.Group(elem_classes=["aws-sidebar-content"]):
507
+ status_display = gr.Textbox(
508
+ value="Stopped",
509
+ label="Current Status",
510
+ interactive=False,
511
+ elem_classes=["aws-status-warning"]
512
+ )
513
+
514
+ status_refresh_btn = gr.Button("Refresh Status", elem_classes=["aws-button-secondary"], size="sm")
515
+
516
+ gr.HTML('<div style="margin: 16px 0; border-bottom: 1px solid #d5dbdb;"></div>')
517
+
518
+ # Auto-refresh controls
519
+ gr.HTML('<div class="aws-form-label">Auto-Refresh Settings</div>')
520
+ auto_refresh_status_cb = gr.Checkbox(
521
+ label="Status monitoring (5s)",
522
+ value=False
523
+ )
524
+ auto_refresh_logs_cb = gr.Checkbox(
525
+ label="Log streaming (10s)",
526
+ value=False
527
+ )
528
+
529
+ # Instance Metrics (placeholder)
530
+ with gr.Group(elem_classes=["aws-sidebar"]):
531
+ gr.HTML('<div class="aws-sidebar-header">πŸ“ˆ Metrics</div>')
532
+ with gr.Group(elem_classes=["aws-sidebar-content"]):
533
+ gr.HTML('''
534
+ <div class="aws-metric">
535
+ <div class="aws-metric-value">0</div>
536
+ <div class="aws-metric-label">CPU Usage (%)</div>
537
+ </div>
538
+ <div class="aws-metric">
539
+ <div class="aws-metric-value">0</div>
540
+ <div class="aws-metric-label">Memory (MB)</div>
541
+ </div>
542
+ <div class="aws-metric">
543
+ <div class="aws-metric-value">0</div>
544
+ <div class="aws-metric-label">Uptime (min)</div>
545
+ </div>
546
+ ''')
547
 
548
+ # Logs Section
549
+ with gr.Group(elem_classes=["aws-container"]):
550
+ gr.HTML('<div class="aws-container-header">πŸ“‹ Application Logs</div>')
551
+ with gr.Group(elem_classes=["aws-container-content"]):
552
+ with gr.Row():
553
+ fetch_logs_btn = gr.Button("Fetch Logs", elem_classes=["aws-button-secondary"])
554
+ gr.HTML('<div style="flex-grow: 1;"></div>')
555
+
556
+ gr.HTML('<div class="aws-form-label" style="margin-top: 12px;">CloudWatch Logs</div>')
557
+ logs_display = gr.Textbox(
558
+ lines=12,
559
+ interactive=False,
560
+ elem_classes=["aws-logs"],
561
+ placeholder="Application logs will appear here...\n\nLogs are automatically captured from your running application.",
562
+ show_label=False
563
+ )
564
 
565
  # Event Handlers
566
  connect_btn.click(
 
625
 
626
  # Footer
627
  gr.HTML("""
628
+ <div style="text-align: center; margin-top: 40px; padding: 20px; background-color: #fafbfc; border-top: 1px solid #d5dbdb; color: #687078; font-size: 12px;">
629
+ <p>Β© 2025, Choco Labs, Inc. All rights reserved.</p>
630
+ <p>Sandbox Compute Service β€’ Dual-Engine Architecture </p>
 
 
631
  </div>
632
  """)
633