File tree Expand file tree Collapse file tree
typescript-adapter/examples Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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 ())
Original file line number Diff line number Diff line change 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 ())
Original file line number Diff line number Diff line change 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+ ```
Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 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 ) ;
Original file line number Diff line number Diff line change 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 ) ;
You can’t perform that action at this time.
0 commit comments