Silver Library

Node.js 로 영상 사이트 구현하기 - EP2 본문

Personal DB/Unclassified record

Node.js 로 영상 사이트 구현하기 - EP2

Silver Archmage 2021. 2. 19. 10:15

const express = require('express')

const app = express()


const PORT = 4000;


function handleListening(){

    console.log(`Listening on: http://localhost:${PORT}`);



function handleHome(req, res){


    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



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!

댓글쓰기 폼