aboutsummaryrefslogtreecommitdiff
path: root/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'index.js')
-rw-r--r--index.js9
1 files changed, 7 insertions, 2 deletions
diff --git a/index.js b/index.js
index 6ea86da..5e753e1 100644
--- a/index.js
+++ b/index.js
@@ -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);