-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
39 lines (32 loc) · 1.04 KB
/
Copy pathindex.js
File metadata and controls
39 lines (32 loc) · 1.04 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
const fs = require("fs");
const express = require("express");
const app = express();
const port = process.argv[2];
app.use(express.static("."));
app.use(express.json());
app.get("/", function(req, res) {
res.writeHead(200, {"Content-Type": "text/html"});
res.end(fs.readFileSync("index.html").toString());
})
const ids = [999];
app.post("/", function (req, res) {
console.log(req.body);
if (req.body.pin == "231203") {
res.writeHead(200, {"Content-Type": "application/json"});
res.end(JSON.stringify({status: true, id: 999}));
} else {
res.writeHead(400, {"Content-Type": "application/json"});
res.end(JSON.stringify({status: false, id: -1}));
};
});
app.get("/nextpage", function (req, res) {
console.log(req.query);
console.log(+req.query.id == ids);
if (+req.query.id in ids) {
ids.filter(v => v != +req.query.id);
res.end("Successfully authed");
} else {
res.redirect("/");
}
})
app.listen(port, function () { console.log(`Running on port ${port}`) });