diff options
Diffstat (limited to 'motto/index.js')
-rw-r--r-- | motto/index.js | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/motto/index.js b/motto/index.js new file mode 100644 index 0000000..28faf69 --- /dev/null +++ b/motto/index.js @@ -0,0 +1,21 @@ +const express = require("express"); +const fs = require("fs"); +const app = express(); + +app.use(express.urlencoded({ extended: true })); +app.use(express.json()); + +app.use("/", express.static(__dirname + "/public")); + +app.get("/api/list", (req, res) => { + fs.readFile("list.txt", "utf8", (err, data) => { + res.send(data); + }); +}); + +app.post("/api/vote", (req, res) => { + console.log(req.body.text, req.body.vote); + res.send("ok"); +}); + +app.listen(3000); |