-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathindex.js
More file actions
36 lines (28 loc) · 755 Bytes
/
index.js
File metadata and controls
36 lines (28 loc) · 755 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const logColor = require("./log-color");
const http = require("http");
const port = 3000;
const server = http.createServer((req, res) => {
res.statusCode = 200;
res.setHeader("Content-Type", "text/plain");
const url = req.url;
switch (url) {
case "/red":
logColor.red("red string");
res.end("red string sent to console");
break;
case "/blue":
logColor.blue("blue string");
res.end("blue string sent to console");
break;
case "/green":
logColor.green("green string");
res.end("green string sent to console");
break;
default:
res.statusCode = 404;
res.end("page not found");
}
});
server.listen(port, () => {
console.log(`Server running at ${port}`);
});