Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemathinc
GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/project/browser-websocket/exec-code.ts
1447 views
1
// Execute code on compute server in compute or filesystem container, or in this project.
2
3
import {
4
handleComputeServerFilesystemExec,
5
handleComputeServerComputeExec,
6
} from "@cocalc/sync-fs/lib/handle-api-call";
7
8
import { executeCode } from "@cocalc/backend/execute-code";
9
10
import type {
11
ExecuteCodeOptions,
12
ExecuteCodeOutput,
13
} from "@cocalc/util/types/execute-code";
14
15
export default async function execCode(opts: ExecuteCodeOptions): Promise<ExecuteCodeOutput> {
16
if (opts.compute_server_id) {
17
if (opts.filesystem) {
18
return await handleComputeServerFilesystemExec(opts);
19
} else {
20
return await handleComputeServerComputeExec(opts);
21
}
22
} else {
23
return await executeCode(opts);
24
}
25
}
26
27