anurag008w commited on
Commit
b38a996
·
1 Parent(s): 87b78f5

Serve env-builder.js on request with error response

Browse files

Add endpoint to serve env-builder.js with error handling

Files changed (1) hide show
  1. health-server.js +11 -0
health-server.js CHANGED
@@ -313,6 +313,17 @@ const server = http.createServer(async (req, res) => {
313
  return res.end(renderEnvBuilder());
314
  }
315
 
 
 
 
 
 
 
 
 
 
 
 
316
  if (pathname === "/" || pathname === "/dashboard") {
317
  const [gatewayReady, jupyterReady] = await Promise.all([
318
  probePort(GATEWAY_HOST, GATEWAY_PORT, "/health"),
 
313
  return res.end(renderEnvBuilder());
314
  }
315
 
316
+ if (pathname === "/env-builder.js") {
317
+ try {
318
+ const js = fs.readFileSync(require("path").join(__dirname, "env-builder.js"), "utf8");
319
+ res.writeHead(200, { "Content-Type": "application/javascript" });
320
+ return res.end(js);
321
+ } catch (exc) {
322
+ res.writeHead(404, { "Content-Type": "text/plain" });
323
+ return res.end(`env-builder.js not found: ${exc.message}`);
324
+ }
325
+ }
326
+
327
  if (pathname === "/" || pathname === "/dashboard") {
328
  const [gatewayReady, jupyterReady] = await Promise.all([
329
  probePort(GATEWAY_HOST, GATEWAY_PORT, "/health"),