From 26ba56205707935f59c413202c3f91010c182d36 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Tue, 1 Sep 2020 17:43:23 +0200 Subject: Very much good --- motto/index.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 motto/index.js (limited to 'motto/index.js') 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); -- cgit v1.2.3