-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserve.js
24 lines (20 loc) · 1.02 KB
/
serve.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
const { HttpServer } = require('http-server');
const opener = require('opener');
const host = '127.0.0.1';
const port = 8000;
function runCompilerBackend() {
console.log("Starting CompilerBackend...");
const { spawn } = require("child_process");
const cmpl = spawn("python", ["-u", "compiler_backend.py", "--localOnly"], { cwd: "CompilerBackend", shell: false });
cmpl.stdout.on("data", data => console.log(`${data.toString().trim()}`));
cmpl.stderr.on("data", data => console.error(`${data}`));
cmpl.on('error', (error) => console.error(`CompilerBackend error: ${error.message}`));
cmpl.on("close", code => console.log(`CompilerBackend stopped with code ${code}`));
}
if (!process.argv.includes("--withoutCompilerBackend"))
runCompilerBackend();
const server = new HttpServer({ cache: -1, showDotfiles: 'false', showDir: 'false' });
server.listen(port, host, function () {
console.log(`Server is listening on ${host}:${port}. Hit CTRL-C to stop the server.`);
opener(`http://${host}:${port}/`);
});