-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
31 lines (26 loc) · 859 Bytes
/
server.js
File metadata and controls
31 lines (26 loc) · 859 Bytes
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
const express = require("express");
const app = express();
app.use(express.static("public"));
app.get("/", function(request, response) {
response.sendFile(__dirname + "/views/index.html");
});
app.get("/link", function(req, res) {
res.sendFile(__dirname + "/views/link.html");
const link = Buffer.from(req.query.l, "base64").toString();
res.set('Cache-Control', 'max-age=0')
res.redirect(308, link);
res.send();
console.log(link);
});
app.get("/input", function(req, res) {
if(req.query.bmark){
res.sendFile(__dirname + "/views/input.html");
}else{
const link = Buffer.from(req.query.l, "utf-8").toString("base64");
res.redirect("/link/?l=" + link);
}
console.log(__dirname);
});
const listener = app.listen(process.env.PORT, function() {
console.log("Your app is listening on port " + listener.address().port);
});