-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
40 lines (38 loc) · 1.19 KB
/
app.js
File metadata and controls
40 lines (38 loc) · 1.19 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
const http = require("http");
const fs = require("fs");
const server = http.createServer((request, response) => {
switch(request.url) {
case "/":
const home = fs.readFileSync("./www/html/home.html");
response.statusCode = 200;
response.setHeader("Content-Type", "text/html");
response.end(home)
break;
case "/bio":
const bio = fs.readFileSync("./www/html/bio.html");
response.statusCode = 200;
response.setHeader("Content-Type", "text/html");
response.end(bio)
break;
case "/services":
const services = fs.readFileSync("./www/html/services.html");
response.statusCode = 200;
response.setHeader("Content-Type", "text/html");
response.end(services)
break;
case "/contact":
const contact = fs.readFileSync("./www/html/contact.html");
response.statusCode = 200;
response.setHeader("Content-Type", "text/html");
response.end(contact)
break;
default:
const notFoundError = fs.readFileSync("./www/html/404.html");
response.statusCode = 404;
response.setHeader("Content-Type", "text/html");
response.end(notFoundError)
}
});
server.listen(3000, "localhost", () => {
console.log("Server running on port 3000");
});