diff --git a/src/main.js b/src/main.js index 3ef4cf2..f4746b3 100644 --- a/src/main.js +++ b/src/main.js @@ -131,4 +131,27 @@ var checkRepost = (url, cbcr) => { var formatSize = (size) => { 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]; -}; \ No newline at end of file +}; + + + +// 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); +}); \ No newline at end of file