-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
55 lines (38 loc) · 1.03 KB
/
server.js
File metadata and controls
55 lines (38 loc) · 1.03 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
// import express framework
const express = require("express")
// initilalise a port
const PORT = 3500
// create an instance of express
const app = express()
app.use(express.json())
// create A Javscript array of object
const studentInfo = {
name :"John",
course :"Full Stack",
duration: "One year",
institution : "Decagon",
grade:{
javaScript : 60,
HTML : 80,
css : 50,
IonicAngular : 50,
Node: 40
}
}
// entry route
// REQUEST : GET localhost:3500/
app.get("/", (req, res)=>{
// res.json({message: 'Welcome to ExpressJS'})
// passing a responds with status code
res.status(200).json({message:"Welcome to expressJS"})
})
// get student info
// REQUEST : GET localhost:3500/studentInfo
app.get("/studentInfo", (rq,res)=>{
// res.status(200).json(studentInfo)\\
res.status(200
).json({message:"List os students and their Information", data : studentInfo})
})
app.listen(PORT, ()=>{
console.log(`sever is ready to run at port : ${PORT}`)
})