-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
54 lines (49 loc) · 1.09 KB
/
index.js
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
const http = require("http");
const fs = require("fs");
const args = require('minimist')(process.argv.slice(2));
let homeContent = "";
let projectContent = "";
let registrationContent = "";
fs.readFile("home.html", (err, home) => {
if (err) {
throw err;
}
homeContent = home;
});
fs.readFile("project.html", (err, project) => {
if (err) {
throw err;
}
projectContent = project;
});
fs.readFile("registration.html", (err, registration) => {
if (err) {
throw err;
}
registrationContent = registration;
});
fs.readFile("home.html", (err, home) => {
if (err) {
throw err;
}
http
.createServer((request, response) => {
let url = request.url;
response.writeHeader(200, { "Content-Type": "text/html" });
switch (url) {
case "/project":
response.write(projectContent);
response.end();
break;
case "/registration":
response.write(registrationContent);
response.end();
break;
default:
response.write(homeContent);
response.end();
break;
}
})
.listen(args.port);
});