-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
43 lines (35 loc) · 855 Bytes
/
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
const express = require("express");
const app = express();
app.use(express.json());
app.get("/", (req, res)=>{
res.sendFile('index.html', {root: __dirname});
});
app.get("/public.js", (req, res)=>{
res.sendFile('public.js', {root: __dirname});
});
let channels = {};
app.post("/postText", (req, res)=>{
console.log("+:", req.body);
channels[req.body.channel] = {
text: req.body.text,
password: req.body.password
};
res.send({
hello: "goodbye"
});
});
app.post("/getText", (req, res)=>{
let data = channels[req.body.channel];
if (data == undefined)
data = "No such channel dipshit";
else
data = (data.password == req.body.password) ? data.text : "Wrong password fuckass";
res.send({
text: data
});
});
let port = process.env.PORT;
if (port == null || port == "") {
port = 6969;
}
app.listen(port);