-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
74 lines (44 loc) · 1.46 KB
/
server.js
File metadata and controls
74 lines (44 loc) · 1.46 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
const express = require('express');
const app = express();
const port = 3003;
const bodyParser = require('body-parser');
const fs = require('fs');
const path = require('path');
const http = require('http');
const catArray = require('./data/cats');
console.log(catArray, `GREAT BIG CATTTS`, catArray[0].number, `WKKKKKKKKKKK`);
app.use(express.static('public'))
app.use(bodyParser.urlencoded({extended: false}));
app.use(express.json());
// CLIENT DATA OBJECT
let fakeDB = [], cleientData;
app.post('/reg', (req, res) => {
console.log(`REQ.BODY`, req.body, req.body.first, `LOOOOOOK ATTTTT MEEEEEE. nowwwwwwww`);
cleientData = req.body;
fakeDB.push(cleientData);
res.json(cleientData)
});
// THE CAT DATA OBJECT
let c, idx = 0, cList = [], catPage, name, image;
app.post('/kat', (req, res) => {
console.log(req.body,`Tes`)
cNum = req.body.catt;
// cNum = parseInt(convertToNum);
console.log(typeof cNum, cNum)
for (c of catArray) {
// console.log(cNum,`CNUMMMMM`, c.number, `NUMBER CHECKKKKK`);
// cList.push(c.number);
if (c.number === cNum) {
console.log("I GOT THAT SHITTTTTTT", c.number, c.image);
name = c.name;
image = c.images
console.log(name, `NAME`, image, `IMAGE`);
}
}
res.json({name, image})
// });
});
////////
app.listen(port, () => {
console.log(`Cat scratching on port ${port}`)
})