Skip to content

Ports and URLs

A server running in the machine is at https://<port>-<id>.box.rookbox.run.

sandbox.commands.run("python3 -m http.server 8000", background=True)
host = sandbox.get_host(8000) # 8000-<id>.box.rookbox.run
await sandbox.commands.run("python3 -m http.server 8000", { background: true });
const host = sandbox.getHost(8000); // 8000-<id>.box.rookbox.run

The address only answers with the e2b-traffic-access-token header. The SDK already holds the machine’s token. Use it in requests:

import urllib.request
req = urllib.request.Request(
f"https://{host}",
headers={"e2b-traffic-access-token": sandbox.traffic_access_token},
)
print(urllib.request.urlopen(req).read().decode())

Without the header, the answer is an access error.

A link opened straight in the browser does not send the header, so it does not work. To see the machine’s screen, use the Desktop. For your own web app, call the URL from your code, as above.

Janela do terminal
rookbox url <id> 8000