全部產品
Search
文件中心

Function Compute:啟動與就緒命令

更新時間:Jul 22, 2026

如需在沙箱中運行 Web 服務等常駐進程,可以在建立沙箱後通過後台命令啟動。

Python 樣本:

server = sandbox.commands.run(
    "python3 -m http.server 8000",
    background=True,
)

host = sandbox.get_host(8000)
print(f"https://{host}")

TypeScript 樣本:

const server = await sandbox.commands.run("python3 -m http.server 8000", {
  background: true,
});

const host = sandbox.getHost(8000);
console.log(`https://${host}`);