-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
90 lines (80 loc) · 1.85 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
let pokemon = [
{
id: 1,
name: 'Bulbasaur',
type: 'grass',
evolves_from: 'egg',
image_url: 'http://www.pokestadium.com/sprites/xy/bulbasaur.gif'
},
{
id: 2,
name: 'Ivysaur',
type: 'grass',
evolves_from: 'Bulbasaur',
image_url: 'http://www.pokestadium.com/sprites/xy/ivysaur.gif'
},
{
id: 3,
name: 'Venusaur',
type: 'grass',
evolves_from: 'Ivysaur',
image_url: 'http://www.pokestadium.com/sprites/xy/venusaur.gif'
},
{
id: 4,
name: 'Charmander',
type: 'fire',
evolves_from: 'egg',
image_url: 'http://www.pokestadium.com/sprites/xy/charmander.gif'
},
{
id: 5,
name: 'Charmeleon',
type: 'fire',
evolves_from: 'Charmander',
image_url: 'http://www.pokestadium.com/sprites/xy/charmeleon.gif'
},
{
id: 6,
name: 'Charizard',
type: 'fire',
evolves_from: 'Charmeleon',
image_url: 'http://www.pokestadium.com/sprites/xy/charizard.gif'
},
{
id: 7,
name: 'Squirtle',
type: 'water',
evolves_from: 'egg',
image_url: 'http://www.pokestadium.com/sprites/xy/squirtle.gif'
},
{
id: 8,
name: 'Wartortle',
type: 'water',
evolves_from: 'Squirtle',
image_url: 'http://www.pokestadium.com/sprites/xy/wartortle.gif'
},
{
id: 9,
name: 'Blastoise',
type: 'water',
evolves_from: 'Wartortle',
image_url: 'http://www.pokestadium.com/sprites/xy/blastoise.gif'
}
];
var express = require('express');
var app = express();
var ejs = require('ejs');
app.set('view engine', 'ejs')
app.get('/pokemon', function(req, res){
res.render('index', {pokemon});
})
app.get('/pokemon/:id', function(req, res){
var pokemon_id = req.params.id;
var myPokemon = pokemon[pokemon_id-1];
res.render('profile', {myPokemon})
})
app.listen(8000, function(){
console.log("Listening at port 8000...");
})