반응형 GET1 [Node.js] http 모듈로 웹으로 GET/POST를 서비스해보자. 1. 개요 Node.js에서 http 모듈로 웹으로 GET/POST를 서비스해 보는 예제이다. 2. 사용법 http 모듈과 fs 모듈을 선언한다. var http = require('http'); var fs = require('fs'); 요청에 대한 onRequest() 함수를 생성한다. 콜백함수의 파라미터로 request와 response를 받는다. function onRequest(request, response) { …(중략)… } http 객체에 createServer() 함수로 Server를 생성하면서 콜백함수로 onRequest를 지정해 준다. http.createServer(onRequest).listen(1337, function() { console.log('http://127... ■ Front-End ■/Node.js 2023. 2. 26. 이전 1 다음 728x90