CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
sagemathinc

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/next/pages/api/v2/jupyter/kernels.ts
Views: 687
1
/*
2
Get all the available Jupyter kernels that the Jupyter API server
3
hosted here provides.
4
5
If project_id is specified, user must be signed in as a collab on that
6
project, and then they get the kernels that are supported by that project.
7
*/
8
import getKernels from "@cocalc/server/jupyter/kernels";
9
import getParams from "lib/api/get-params";
10
import getAccountId from "lib/account/get-account";
11
12
export default async function handle(req, res) {
13
const { project_id } = getParams(req);
14
const account_id = project_id != null ? await getAccountId(req) : undefined;
15
try {
16
res.json({
17
kernels: await getKernels({ project_id, account_id }),
18
success: true,
19
});
20
} catch (err) {
21
res.json({ error: `${err.message}` });
22
return;
23
}
24
}
25
26