Skip to main content
Execute Python and JavaScript code safely in isolated GravixLayer sandboxes with comprehensive error handling and execution control.

Basic Code Execution

Simple Python Code

gravixlayer sandbox code YOUR_SANDBOX_ID "print('Hello World!')"
Output:
Hello World!

Multi-line Code

gravixlayer sandbox code YOUR_SANDBOX_ID "
import math
import datetime
print(f'Current time: {datetime.datetime.now()}')
print(f'Pi value: {math.pi}')
numbers = [1, 2, 3, 4, 5]
squares = [x**2 for x in numbers]
print(f'Squares: {squares}')
"
Output:
Current time: 2025-01-27 10:30:15.123456
Pi value: 3.141592653589793
Squares: [1, 4, 9, 16, 25]

Language-Specific Execution

Python Code (Default)

gravixlayer sandbox code YOUR_SANDBOX_ID "print('Python code')" --language python
Output:
Python code

JavaScript Code

# Create JavaScript sandbox first
gravixlayer sandbox create --provider gravix --region eu-west-1 --template javascript-base-v1

# Run JavaScript code
gravixlayer sandbox code YOUR_SANDBOX_ID "console.log('JavaScript code');" --language javascript
Output:
Created sandbox: 880g9622-h5ce-74g7-d049-779988773333
JavaScript code

Next Steps