-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.js
36 lines (28 loc) · 923 Bytes
/
index.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
var express = require('express');
var bodyParser = require('body-parser');
var app = express();
// app.set is going to be used for setting app
app.set("view engine", "ejs");
// app.use is for middleware (plugins)
app.use(bodyParser.urlencoded({extended: false}))
app.use(express.static(__dirname + '/public'));
// Faux DB
var emails = []
// Our email form
app.get("/", function(req, res) {
// res.send("This is our first express app");
res.render("email")
});
// Our post data
app.post("/process", function(req,res) {
emails.push(req.body.email)
// res.send(req.body);
res.render("subscribe", {allEmails: emails})
})
app.get("/add/:x/:y", function(taco, burrito) {
burrito.send("It is... " + (parseInt(taco.params.x) + parseInt(taco.params.y)))
})
app.get("/multiply/:x/:y", function(taco, burrito) {
burrito.send("It is... " + (parseInt(taco.params.x) * parseInt(taco.params.y)))
})
app.listen(3000);