Skip to content

Commit 3505f3b

Browse files
authored
Merge pull request #144 from mavdol/integrations/v0.7.1/examples
Add adaters examples
2 parents 170e80f + 4d4cb3c commit 3505f3b

6 files changed

Lines changed: 86 additions & 0 deletions

File tree

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import asyncio
2+
from capsule_adapter import run_javascript
3+
4+
async def main():
5+
print("Executing JavaScript code inside Capsule sandbox...")
6+
7+
result = await run_javascript("""
8+
console.log("Hello from JavaScript!");
9+
let x = 5 + 3;
10+
x * 2;
11+
""")
12+
13+
print("\n--- Sandbox Output ---")
14+
print(result)
15+
16+
if __name__ == "__main__":
17+
asyncio.run(main())
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import asyncio
2+
from capsule_adapter import run_python
3+
4+
async def main():
5+
print("Executing Python code inside Capsule sandbox...")
6+
7+
result = await run_python("""
8+
print("Hello from Python!")
9+
x = 5 + 3
10+
x * 2
11+
""")
12+
13+
print("\n--- Sandbox Output ---")
14+
print(result)
15+
16+
if __name__ == "__main__":
17+
asyncio.run(main())
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Run Examples
2+
3+
## Quick Start
4+
5+
```bash
6+
npm install
7+
8+
# Run JavaScript
9+
npx tsx run-javascript.ts
10+
11+
# Run Python
12+
npx tsx run-python.ts
13+
```
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "examples",
3+
"version": "1.0.0",
4+
"description": "",
5+
"license": "ISC",
6+
"author": "",
7+
"type": "module",
8+
"main": "index.js",
9+
"scripts": {
10+
"test": "echo \"Error: no test specified\" && exit 1"
11+
},
12+
"dependencies": {
13+
"@capsule-run/adapter": "latest"
14+
}
15+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { runJavaScript } from "@capsule-run/adapter";
2+
3+
console.log("Executing JavaScript code inside Capsule sandbox...");
4+
5+
const result = await runJavaScript(`
6+
console.log("Hello from JavaScript!")
7+
let x = 5 + 3
8+
x * 2
9+
`)
10+
11+
console.log("\n--- Sandbox Output ---");
12+
console.log(result);
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { runPython } from "@capsule-run/adapter";
2+
3+
console.log("Executing Python code inside Capsule sandbox...");
4+
5+
const result = await runPython(`
6+
print("Hello from Python!")
7+
x = 5 + 3
8+
x * 2
9+
`)
10+
11+
console.log("\n--- Sandbox Output ---");
12+
console.log(result);

0 commit comments

Comments
 (0)