Server

AWS/EC2

AWS EC2 Spring boot& React 3편-Node.js 설치 및 React App생성 (Amazon Linux 2 AMI 기준 )

이번 시간에는 프론트단(React.js, Vue.js, Angular.js)을 돌릴 수 있는 Node.js 설치와 그다음 React App을 구동해 보겠다 일단 EC2 인스턴스에 Terminal로 접속하도록 하자 혹시 인스턴스가 없는 경우 아래 링크 클릭 https://initstory.tistory.com/89?category=1029330 인스턴스가 있는데, 중지를 한 경우 아래의 링크의 2번까지!! https://initstory.tistory.com/90?category=1029330 1. Node.js Install curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash 위의 코드를 복사한 다음 넣고 ente..

Web Programming/Node.js

Node.js POST 하기

이번에는 POST방식으로 전송했을 때 받는 법을 하겠다! 아래의 코드의 html 파일이 필요하다 여기서 action 을 정해준다. 여기에는 전송하고 싶은 URL를 적어주면 된다! 그다음 server.js에서 아래의 코드를 추가한다 else if (pathname === '/create') { dataAll = ''; request.on('data', function (data) { dataAll = dataAll + data; }); request.on('end', function () { var result = querystring.parse(dataAll); console.log(parsedQuery); response.writeHead(200); response.end(result.id + ' An..

Web Programming/Node.js

Node.js GET 하기

브라우저에서 URL를 보면 【?id=helloworld&name=initstory】 이런 식의 주소를 본 적이 있을 것이다 이것을 queryString이라고 말하며 key value라고 보면 된다 id의 값은 hellworld name의 값은 initstory 그래서 이것을 GET (받는다) 하는 것을 해볼 것이다 id를 GET하면 helloworld가 값이 될 것이고 name을 GET하면 initstory가 값이 되게끔.. 그전에 앞서 Node.js의 URL모듈을 또 변수에 넣어보자 var url = require('url'); 그다음은 아래의 코드를 입력하라 이전에 내가 말한 request에는 사용자가 요청한 것이 담겨 있다고 했다 URL주소도 안에 담겨있고, 그것을 불러 myUrl이라는 변수에 넣어..

Web Programming/Node.js

Node.js Server 구축

Node.js를 깔았으니 이번엔 서버 구축을 해보겠다 일단 js 파일 하나를 만들어 본다 Node.js에는 여러 가지 모듈을 들고 있다 그중 http라는 모듈을 사용해서 서버를 구축해보자 일단 http 모듈을 변수에 담아서 사용해야 한다 var http = require('http'); 그다음 아래의 코드를 추가한다 이게 가장 기본적인 서버 구축하는 법이다 http모듈 안에는 createServer가 있음 var server = http.createServer(function(request,response){ response.writeHead(200); response.end('Hello World'); }); 웹은 요청 ( request ), 응답 ( response ) 가있는데 request는 사용자..

INICO
'Server' 태그의 글 목록