Feature
Preview URLs
Expose any port via public URLs instantly. No tunnels, no configuration — just start your server and get a public HTTPS URL.
preview_url.py
1from hopx_ai import Sandbox
2
3sandbox = Sandbox.create(template="code-interpreter")
4
5# Start a web server
6sandbox.run_code_background("""
7from http.server import HTTPServer, SimpleHTTPRequestHandler
8import os
9os.chdir('/workspace')
10HTTPServer(('0.0.0.0', 8080), SimpleHTTPRequestHandler).serve_forever()
11""")
12
13# Get the public preview URL
14url = sandbox.get_preview_url(port=8080)
15print(f"Public URL: {url}")
16# https://8080-abc123.us-east.vms.hopx.dev/
17
18# Multiple ports work the same way
19sandbox.run_code_background("python -m http.server 3000")
20url_3000 = sandbox.get_preview_url(port=3000)
21print(f"Another URL: {url_3000}")
22
23# URLs are predictable:
24# https://{port}-{sandbox_id}.{region}.vms.hopx.dev/Instant URLs
Get a public URL for any port immediately
HTTPS Included
All preview URLs are served over HTTPS
Isolated Access
Each sandbox gets its own unique URL prefix
No Config
No port forwarding or tunnel setup required