Notice
Recent Posts
Recent Comments
Link
투케이2K
27. (NodeJs) [Mac Os] [Cookie] : http 내장 모듈 사용해 node js 쿠키 값 만들기 수행 본문
[개발 환경 설정]
개발 툴 : VS CODE
개발 언어 :NodeJs
[방법 설명]
[app.js : 소스 코드]
// ----------------------------------------------------------------------------------------------
const express = require('express')
const app = express()
app.set('view engine', 'ejs') // [Page] : [Render]
app.set('views', './views') // [Page] : [Render]
//app.use(express.urlencoded({ extended: true })) // [Http] : [URL] : [Encode]
app.use(express.json()) // [Http] : [Body] : [Json]
const http = require('http') // [Node 에서 Cookie 사용]
// ----------------------------------------------------------------------------------------------
// [Get] : Path = [/] : http://localhost:3000/
app.get('/', function (req, res) {
console.log("")
console.log("==============================================================================")
console.log("[API] :: [Get] :: [Path = /] :: [Start]")
console.log("==============================================================================")
console.log("")
// [Web Return Response]
res.send('Hello World !!')
})
// ----------------------------------------------------------------------------------------------
// [Server] : [Start]
http.createServer(function(request, response){
response.writeHead(200, {
'Set-Cookie':['SESSION_COOKIE=ADBG35443EFEFEFE']
});
response.end('End_Cookie_Setting');
console.log("")
console.log("==============================================================================")
console.log("[Server] :: [Port = 3000] :: [Start]")
console.log("==============================================================================")
console.log("")
}).listen(3000);
// ----------------------------------------------------------------------------------------------
[결과 출력]
반응형
'NodeJs' 카테고리의 다른 글
Comments