Skip to content

Commit

Permalink
update express server
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelja committed Jan 29, 2018
1 parent c68de3c commit e56b4a5
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion server.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,15 @@ function makeId() {
return text;
}

app.all('/*', function(req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "X-Requested-With");
next();
});

app.get("/kill/*", function(req, res) {
let id = req.params[0];
console.log(runningProcesses);
runningProcesses[id]["process"].kill();
res.send("killed");
});
Expand All @@ -32,7 +39,7 @@ app.get("/stderr/*", function(req, res) {

app.get("/end/*", function(req, res) {
let id = req.params[0];
if (runningProcesses[id]["end"]) {
if (runningProcesses[id]["end"] && runningProcesses[id]["stdout"].length === 0 && runningProcesses[id]["stderr"].length === 0) {
delete runningProcesses[id];
res.send(true);
} else {
Expand Down

0 comments on commit e56b4a5

Please sign in to comment.