remove unnecisary async lambda

master
Avril 4 years ago
parent 691c14eede
commit 9ed73e48fc
Signed by: flanchan
GPG Key ID: 284488987C31F630

@ -5,21 +5,19 @@ const fs = require('fs'),
console.log("Starting static server on port "+config.STATIC_PORT); console.log("Starting static server on port "+config.STATIC_PORT);
(async () => { http.createServer((req, res) => {
await http.createServer((req, res) => { let url = req.url;
let url = req.url; if(!req.url || req.url == "" || req.url == "/") url = "/index.html";
if(!req.url || req.url == "" || req.url == "/") url = "/index.html"; fs.readFile(config.STATIC_LOCATION + url, (err, data) => {
fs.readFile(config.STATIC_LOCATION + url, (err, data) => { if(err) {
if(err) { console.log("Failed to retreive requested url '"+url+"': "+err);
console.log("Failed to retreive requested url '"+url+"': "+err); res.writeHead(404);
res.writeHead(404); res.end(JSON.stringify(err));
res.end(JSON.stringify(err)); return;
return; } else {
} else { console.log("Writing "+url);
console.log("Writing "+url); res.writeHead(200);
res.writeHead(200); res.end(data);
res.end(data); }
} });
}); }).listen(config.STATIC_PORT);
}).listen(config.STATIC_PORT);
})();

Loading…
Cancel
Save