-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver1.js
More file actions
67 lines (53 loc) · 1.31 KB
/
server1.js
File metadata and controls
67 lines (53 loc) · 1.31 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
// Dependencies
// ===========================================================
var express = require("express");
var app = express();
var PORT = 3000;
// Data
// ===========================================================
var yoda = {
name: "Yoda",
role: "Jedi Master",
age: 900,
forcePoints: 2000
};
var darthmaul = {
name: "Darth Maul",
role: "Sith Lord",
age: 200,
forcePoints: 1200
};
// Create one more data entry for the character Obi Wan Kenobi.
// Enter any values you like for the parameters following the same format as the Yoda and Darth Maul character
//
var obiwan = {
name: "Obi Wan",
role: "Jedi Master",
age: 59,
forcePoints: 1500
};
//
// Routes
// ===========================================================
app.get("/", function(req, res) {
res.send("Welcome to the Star Wars Page!");
});
app.get("/yoda", function(req, res) {
res.json(yoda);
});
app.get("/darthmaul", function(req, res) {
res.json(darthmaul);
});
// Create a new Express route that leads users to the new Obi Wan Kenobi Data
// Follow the same format as the Yoda and Darth Maul routes
//
app.get("/obiwan", function(req, res) {
res.json(obiwan);
});
//
//
// Listener
// ===========================================================
app.listen(PORT, function() {
console.log("App listening on PORT " + PORT);
});