-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
33 lines (24 loc) · 719 Bytes
/
Copy pathindex.js
File metadata and controls
33 lines (24 loc) · 719 Bytes
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
const express =require("express")
const app =express();
const path =require("path");
const port=8080;
app.set("view engine","ejs");
app.set("views", path.join(__dirname,"/views"));
app.get("/",(req,res)=>{
res.render("home.ejs");
});
app.get("/ig/:username",(req,res)=>{
const followers=["adams","bob","steve","abc"]
let {username}= req.params;
res.render("instagram.ejs",{username,followers});
})
app.get("/hello",(req,res)=>{
res.send("hello");
});
app.get("/rolldice",(req,res)=>{
let diceVal=Math.floor(Math.random()*6)+1
res.render("rolldice.ejs",{ num: diceVal});
});
app.listen(port,()=>{
console.log(`listening on port ${port} `);
});