-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
52 lines (40 loc) · 1.26 KB
/
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
var express = require("express");
var app = express();
const bodyParser = require("body-parser");
app.use(bodyParser.urlencoded({ extended: true }));
app.use(express.static("public"));
// set the view engine to ejs
app.set("view engine", "ejs");
// use res.render to load up an ejs view file
// index page
app.get("/", function (req, res) {
res.render("pages/index");
});
// JX page
app.get("/jx", function (req, res) {
res.render("pages/jx");
});
// about page
app.get("/about", function (req, res) {
res.render("pages/about");
});
app.get("/stores", function (req, res) {
res.render("pages/stores", { data: { x: 51.0517983, y: 4.4515703 } });
});
app.post("/foo", function (req, res) {
res.send({ baz: "bat" });
});
app.post("/new-todo", function (req, res) {
console.log("posted to /new-todo with:", req.body);
res.render("partials/todos", { data: req.body });
});
app.post("/new-todo-jx", function (req, res) {
console.log("posted to /new-todo-jx with:", req.body);
res.render("partials/todos-jx", { data: req.body });
});
app.post("/stores-map", function (req, res) {
console.log("posted to /stores-map with:", req.body);
res.render("partials/leaflet-form", { data: req.body });
});
app.listen(8080);
console.log("Server is listening on port 8080");