-
Notifications
You must be signed in to change notification settings - Fork 0
/
NODE
52 lines (31 loc) · 779 Bytes
/
NODE
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
const http = require('http');
const fs = require('fs');
const { url } = require('inspector');
const server = http.createServer((req, res) => {
console.log('ok')
res.setHeader('content-type', 'text/html');
let path = ("./views/");
switch (res = url) {
case './':
path += 'home.html';
break
case './about':
path += 'abot.html';
break
// case './':
// path+='home.html';
// break
}
fs.readFile(path, (err, data) => {
if (err) {
console.log(err)
}
else {
res.write(data);
res.end()
}
})
});
server.listen(3000, 'localhost', () => {
console.log('server started')
});