-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
23 lines (19 loc) · 687 Bytes
/
Copy pathindex.js
File metadata and controls
23 lines (19 loc) · 687 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
const http = require('http');
const fs = require('fs');
const myServer = http.createServer((req, res) => {
const log = `${Date.now()}: ${req.url} New req Received\n`;
fs.appendFile("log.txt", log, (err, data) => {
switch (req.url) {
case '/': res.end("Home Page");
break
case '/about': res.end("I am Neha Bharti");
break
default: res.end("404 Not found");
}
// res.end("Hello from server");
});
// console.log("New request received");
// console.log(req.headers);
// res.end("Hello from server");
});
myServer.listen(8080, () => console.log("server started successfully!"));