Skip to content

Sandbox

Execute JavaScript, Python, or shell commands in isolated environments.

3 modules

ModuleDescription
JavaScript चलाएंNode.js के माध्यम से टाइमआउट के साथ JavaScript कोड चलाएं
Python चलाएंसबप्रोसेस में टाइमआउट के साथ Python कोड चलाएं
शेल चलाएंटाइमआउट और पर्यावरण नियंत्रण के साथ शेल कमांड चलाएं

Modules

JavaScript चलाएं

sandbox.execute_js

Node.js के माध्यम से टाइमआउट के साथ JavaScript कोड चलाएं

Parameters:

NameTypeRequiredDefaultDescription
codestringYes-Node.js के माध्यम से चलाने के लिए JavaScript कोड
timeoutnumberNo10सेकंड में निष्पादन टाइमआउट

Output:

FieldTypeDescription
stdoutstringस्क्रिप्ट से मानक आउटपुट
stderrstringस्क्रिप्ट से मानक त्रुटि
exit_codenumberप्रक्रिया निकास कोड (0 = सफलता)
execution_time_msnumberमिलीसेकंड में निष्पादन समय

Example: Simple console.log

yaml
code: console.log("Hello, World!");
timeout: 10

Example: JSON processing

yaml
code: const data = { name: "test", value: 42 };
console.log(JSON.stringify(data, null, 2));

Python चलाएं

sandbox.execute_python

सबप्रोसेस में टाइमआउट के साथ Python कोड चलाएं

Parameters:

NameTypeRequiredDefaultDescription
codestringYes-चलाने के लिए Python कोड
timeoutnumberNo10सेकंड में निष्पादन टाइमआउट
allowed_modulesarrayNo-इम्पोर्ट करने योग्य मॉड्यूल की श्वेतसूची (सभी की अनुमति के लिए खाली छोड़ें)

Output:

FieldTypeDescription
stdoutstringस्क्रिप्ट से मानक आउटपुट
stderrstringस्क्रिप्ट से मानक त्रुटि
exit_codenumberप्रक्रिया निकास कोड (0 = सफलता)
execution_time_msnumberमिलीसेकंड में निष्पादन समय

Example: Simple print

yaml
code: print("Hello, World!")
timeout: 10

Example: Math calculation

yaml
code: import math
print(math.pi)
allowed_modules: ["math"]

शेल चलाएं

sandbox.execute_shell

टाइमआउट और पर्यावरण नियंत्रण के साथ शेल कमांड चलाएं

Parameters:

NameTypeRequiredDefaultDescription
commandstringYes-चलाने के लिए शेल कमांड
timeoutnumberNo10सेकंड में निष्पादन टाइमआउट
working_dirstringNo-कमांड के लिए कार्य निर्देशिका
envobjectNo-सेट करने के लिए अतिरिक्त पर्यावरण वेरिएबल्स (वर्तमान पर्यावरण के साथ मिलाए गए)

Output:

FieldTypeDescription
stdoutstringकमांड से मानक आउटपुट
stderrstringकमांड से मानक त्रुटि
exit_codenumberप्रक्रिया निकास कोड (0 = सफलता)
execution_time_msnumberमिलीसेकंड में निष्पादन समय

Example: Simple echo

yaml
command: echo "Hello, World!"
timeout: 10

Example: List files with custom working directory

yaml
command: ls -la
working_dir: /tmp

Released under the Apache 2.0 License.