Silver Library (Archived)
Node.js 로 영상 사이트 구현하기 - EP2 본문
const express = require('express')
const app = express()
const PORT = 4000;
function handleListening(){
console.log(`Listening on: http://localhost:${PORT}`);
}
function handleHome(req, res){
console.log('req');
res.send("Hello from home!")
}
function handleProfile(req, res){
res.send("You are on my profile")
}
app.get("/", handleHome)
app.get("/profile", handleProfile);
app.listen(PORT, handleListening);
This handleHome function, calls two things.
1. request object
2. response object
Note.
If I send id or password stuff to the URL in POST way,
Then I am getting the information with the request object.
Keep calm and read through that bold code again.
Then what about redirecting URL with displaying the content I desired?
1. use app.get("/name-of-url-you-want", name of function you want to send back to user[response])
Then input http://localhost:4000/profile
If you can see the message you input in function handleProfile, All good!
'Personal DB > Unclassified record' 카테고리의 다른 글
nodejs EP 4 - middleware (0) | 2021.02.19 |
---|---|
nodejs 로 영상 사이트 구현하기 - EP 3 (0) | 2021.02.19 |
Node.js 로 영상 사이트 구현화 하기 - EP1 (0) | 2021.02.19 |
Django - checklist : when seeding is not working (lambda) (0) | 2021.02.10 |
Self-check amid copying airbnb website (0) | 2021.02.03 |