forked from dadheech-vartika/She-Help
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
33 lines (27 loc) · 935 Bytes
/
server.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
const express = require("express");
const path = require("path");
const app = express();
const port = 3000;
const recognition = require("./controller/recognition");
const blockchain = require("./controller/blockchain");
const bodyParser = require("body-parser");
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
app.get("/", (req, res) =>
res.sendFile(path.join(__dirname + "/pages/index.html"))
);
app.post("/submit", async (req, res) => {
console.log(req.body);
let payload = {
u: req.body.user,
a: req.body.amount
};
console.log(payload);
await blockchain.submitTransaction(payload);
let info = await blockchain.getTransactions();
console.log(info[info.length - 1]);
res.send(info[info.length - 1].r);
// res.end("yes");
// res.sendFile(path.join(__dirname + '/pages/index.html'))
});
app.listen(port, () => console.log(`Example app listening on port ${port}!`));