Repository navigation
Expand file tree
/
Copy pathswitch.js
More file actions
60 lines (53 loc) · 1.59 KB
/
Copy pathswitch.js
File metadata and controls
60 lines (53 loc) · 1.59 KB
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
51
52
53
54
55
56
57
58
59
60
const http = require ('http');
const port = 8000;
const fs = require ('fs');
const app = http.createServer((req, res)=>{
switch(req.url){
case "/":
fs.readFile(__dirname + "/sample.html", (error, data)=>{
if (error){
console.log(error.message)
}else{
res.setHeader('Content-Type', 'text/html');
res.end(data);
}
})
break;
case "/girls":
fs.readFile(__dirname + "/girls.html", (error, data)=>{
if (error){
console.log(error.message)
}else{
res.setHeader('Content-Type', 'text/html');
res.end(data);
}
})
break;
case "/boys":
fs.readFile(__dirname + "/boys.html", (error, data)=>{
if (error){
console.log(error.message)
}else{
res.setHeader('Content-Type', 'text/html');
res.end(data);
}
})
break;
case "/staff":
fs.readFile(__dirname + "/staff.html", (error, data)=>{
if (error){
console.log(error.message)
}else{
res.setHeader('Content-Type', 'text/html');
res.end(data);
}
})
break;
default:
res.setHeader('Content-Type', 'text/plain');
res.end("thank you");
}
})
app.listen(port, ()=>{
console.log('listening on port')
})