From a775a4c988a3a55c4b1d4436053c2997e76563e7 Mon Sep 17 00:00:00 2001 From: tgpethan Date: Sat, 4 Jan 2020 12:16:38 +0000 Subject: [PATCH] Add comments to example_request_handler --- modules/example_request_handler.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/example_request_handler.js b/modules/example_request_handler.js index b5d458d..b06f418 100644 --- a/modules/example_request_handler.js +++ b/modules/example_request_handler.js @@ -29,11 +29,14 @@ module.exports = { res - Response from server */ + // Make sure the file exists fs.access(__dirname + BASE_PATH + "/files" + req.url, fs.F_OK, error => { if (error) { + // File doesn't exist, return a 404 to the client. global.modules.consoleHelper.printWarn(emoji.page, `${req.method}: ${req.url} was requested - Returned 404`); res.status(404).send("404!
Revolution"); } else { + // File does exist, send the file back to the client. global.modules.consoleHelper.printInfo(emoji.page, `${req.method}: ${req.url} was requested`); res.sendFile(__dirname + BASE_PATH + "/files" + req.url); }