Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,18 @@ export class Server {
*/
private createServer(): HttpServer {
return createServer((req, res) => {
this.serveData(req, res);
this.serveWebsite(req, res);
if (!this.serveData(req, res)) {
this.serveWebsite(req, res); // only serve website if request was not served from serveData
}
});
}

/**
* Serves the plot data at /data/:id of the container[id].
* It markes the container as opened and not pending anymore.
* @param req
* @param res
* @param res
* @returns {boolean} - Whether the request was served or not
*/
private serveData(req: IncomingMessage, res: ServerResponse) {
if (req && req.url && req.url.match(/data\/[0-9]+/)) {
Expand All @@ -109,7 +111,9 @@ export class Server {

res.end(JSON.stringify(temporaryPlots));
this.close();
return true; // request successfully server
}
return false; // request not served
}

/**
Expand Down