-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
122 lines (115 loc) · 3.54 KB
/
server.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
const { readFileSync, rmSync } = require("fs");
const http = require("http");
const url = require("url");
var serv=http.createServer();
var request = require('request');
var querystring = require('querystring');
var util = require('util');
serv.on("request",(req,res)=>{
var pathName=url.parse(req.url).pathname;
console.log(pathName);
switch(pathName){
case "/":
var data = readFileSync("./index.html");
res.end(data);
break;
case "/css/style.css":
var data = readFileSync("./css/style.css");
res.end(data);
break;
case "/img/code.png":
var data = readFileSync("./img/code.png");
res.end(data);
break;
case "/img/level10.png":
var data = readFileSync("./img/level10.png");
res.end(data);
break;
case "/js/ajax.js":
var data = readFileSync("./js/ajax.js");
res.end(data);
break;
case "/favicon.ico":
var data = readFileSync("./favicon.ico");
res.end(data);
break;
case "/level1":
var data = readFileSync("./level1.html");
res.end(data);
break;
case "/2008":
var data = readFileSync("./level2.html");
res.end(data)
break;
case "/class":
var data = readFileSync("./level3.html");
res.end(data)
break;
case "/Lucida_Console":
var data = readFileSync("./level4.html");
res.end(data);
break;
case "/80439751":
var data = readFileSync("./level5.html");
res.end(data);
break;
case "/absolute":
var data = readFileSync("./level6.html");
res.end(data);
break;
case "/NaN&0":
var data = readFileSync("./level7.html");
res.end(data);
break;
case "/NaN|0":
var data = readFileSync("./level7.html");
res.end(data);
break;
case "/NaN^0":
var data = readFileSync("./level7.html");
res.end(data);
break;
case "/NaN=0":
var data = readFileSync("./level7.html");
res.end(data);
break;
case "/31337":
var data = readFileSync("./level8.html");
break;
case "/All_of_them_can_be_used_as_backend":
var data = readFileSync("./level9.html");
res.end(data);
break;
case "/nodejs_flex_reverse_proxy":
var data = readFileSync("./level10.html");
res.end(data);
break;
case "/w3ll_d0n3":
var data = readFileSync("./congrats.html");
res.end(data);
break;
default:
var data = readFileSync("./err.html");
res.writeHead(404, {"Content-Type":"text/html; charset=utf-8"});
res.end(data);
break;
}
var post = '';
req.on('data', function(chunk){
post += chunk;
});
req.on('end', function(){
post = querystring.parse(post);
if ( post.Go != undefined) {
var data = readFileSync("./answer.html");
res.end(data);
} else {
var data = readFileSync("./level8.html");
res.end(data);
}
return;
});
});
serv.listen("1234",()=>{
console.log("serv running on http://127.0.0.1:1234");
});