-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
55 lines (43 loc) · 1.63 KB
/
app.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
const express = require('express');
const app = express();
const bodyparser = require('body-parser');
app.use(bodyparser.urlencoded({ extended: true }));
app.use(express.static('public'));
const purchase = require('./classes/purchase');
const thisPurchase = new purchase(false, 0, [], 0);
app.listen(3030,function(err){
});
app.get('/', (req,res)=>{
res.sendFile(__dirname+"/public/html/index.html")
});
app.post('/checkbox-value', (req, res) => {
const itc = req.body.internetconnection;
thisPurchase.setInternetConnection(itc)
console.log("Internet Connection has the value: ", itc);
res.send({ "status": 200, "totalprice": thisPurchase.totalPrice });
});
app.post('/addphoneline', (req, res) => {
thisPurchase.addPhoneLine();
console.log("Added a phone line");
res.send({ "status": 200, "totalprice": thisPurchase.totalPrice });
});
app.post('/subtractphoneline', (req, res) => {
thisPurchase.subtractPhoneLine();
console.log("Subtracted a phone line");
res.send({ "status": 200, "totalprice": thisPurchase.totalPrice });
});
app.post('/addcellphone', (req, res) => {
const cellphone = req.body.cellphone;
thisPurchase.addCellPhone(cellphone)
console.log("Added: " + cellphone);
res.send({ "status": 200, "totalprice": thisPurchase.totalPrice });
});
app.post('/removecellphone', (req, res) => {
const cellphone = req.body.cellphone;
thisPurchase.removeCellPhone(cellphone)
console.log("Removed: "+ cellphone);
res.send({ "status": 200, "totalprice": thisPurchase.totalPrice });
});
app.post('/buy', (req, res) => {
res.send({ "status": 200, "thisPurchase": thisPurchase });
});