aboutsummaryrefslogtreecommitdiff
path: root/motto/index.js
blob: 28faf698115757d17284d5e3905181eb82b2d704 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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);