Skip to content

Latest commit

 

History

History

code-runner

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

README.md

code-runner — Sandboxed Python execution API

A FastAPI service that executes arbitrary Python code in subprocess isolation. Each request runs in its own process within the MicroVM.

API Demo

Deploy

./deploy.sh apps/code-runner --private

API

POST /run

// Request
{"code": "print(1+1)", "timeout": 5}

// Response
{"stdout": "2\n", "stderr": "", "exit_code": 0, "duration_ms": 12}

GET /health

{"status": "ok", "runtime": "microvm"}

Example client

./apps/code-runner/example-client.sh

Local development

pip install -r requirements.txt
uvicorn main:app --port 8080

Use case

Backend service for AI coding assistants, automated testing, REPL backends, or code evaluation in LMS platforms. Your application calls this API; users never interact with it directly.

Security notes

  • Code runs in subprocess isolation (not a full container per request)
  • Timeout enforced server-side (max 30s)
  • Output truncated to prevent memory exhaustion (100KB stdout, 10KB stderr)
  • The MicroVM itself provides the hard isolation boundary via Firecracker