import { Sandbox } from '@e2b/code-interpreter'
const sandbox = await Sandbox.create()
// Start a simple HTTP server inside the sandbox.
const process = await sandbox.commands.run('python -m http.server 3000', { background: true })
const host = sandbox.getHost(3000)
const url = `https://${host}`
console.log('Server started at:', url)
// Fetch data from the server inside the sandbox.
const response = await fetch(url);
const data = await response.text();
console.log('Response from server inside sandbox:', data);
// Kill the server process inside the sandbox.
await process.kill()