modified: src/main.js

This commit is contained in:
Flummi 2016-08-14 20:48:34 +02:00
parent 6b5089f19b
commit ac505387c6

View File

@ -132,3 +132,26 @@ var formatSize = (size) => {
var i = Math.floor(Math.log(size) / Math.log(1024)); var i = Math.floor(Math.log(size) / Math.log(1024));
return (size / Math.pow(1024, i)).toFixed(2) * 1 + ' ' + ['B', 'kB', 'MB', 'GB', 'TB'][i]; return (size / Math.pow(1024, i)).toFixed(2) * 1 + ' ' + ['B', 'kB', 'MB', 'GB', 'TB'][i];
}; };
// Webserver
var handleRequest = (request, response) => {
var tmpres = "";
if(request.url == "/") {
sql.query("select * from `f0ck`.`items`", (err, rows, fields) => {
rows.forEach((e,i,a) => {
tmpres += e.src+"\n";
});
});
}
else {
tmpres = "404";
}
setTimeout(()=>{response.end(tmpres);},1000);
};
var server = http.createServer(handleRequest);
server.listen(cfg.webserver.port, () => {
console.log("Server listening on: http://localhost:%s", cfg.webserver.port);
});