diff options
Diffstat (limited to 'index.js')
-rw-r--r-- | index.js | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -1,8 +1,13 @@ const http = require('http'); -http.createServer((req, res) => { +const requestHandler = (req, res) => { + console.log(`${req.method} ${req.url}`); res.writeHead(200, {'Content-Type': 'text/html; charset=utf-8'}); res.end('<h1>lol</h1>'); +}; -}).listen(8080, () => console.log('Server started on port 8080.')); +const onServerStart = () => console.log('Server started on port 8080.'); + +const server = http.createServer(requestHandler); +server.listen(8080, onServerStart); |