REST API란? REST 와 API의 합성어입니다. REST는 통신 체계의 스타일을 규정한 아키텍처입니다. Restful API란? REST 통신 체계 스타일을 준수한 API입니다. myRestBack.js const http = require("http"); const fs = require("fs").promises; const users = {}; // 데이터 저장용 http .createServer(async (req, res) => { try { if (req.method === "GET") { if (req.url === "/") { const data = await fs.readFile("./myRest.html"); // 메인주소일때는 myRest.html 즉 기본이 되는 메인 html..
Server.js const http = require('http'); // http 모듈 생성 http.createServer((req, res) => { // http 서버 생성 res.write('Hello server!') // html태그 전송 res.end('Hello hanamDeveloper!') // 서버 종료와 동시에 html태그 전송 }).listen(8080, () => { // 8080 port로 생성 console.log('포트 8080에서 서버 대기 중입니다.') }) 이런식으로 코드를 구성해도 서버는 잘 구동되지만 html태그를 직접 하면 코드의 줄도 길어질뿐만아니라 행동에도 제약이 생긴다. 그래서 fs객체를 이용해서 파일을 읽어서 코드를 구성한다. 우선 html파일을 만들어..
HTTP란? HTTP란 (HyperText Transfer Protocol)의 약자이다. 클라이언트와 서버가 서로 대화 (응답과 요청) 을 하기 위해서는 하나의 규약을 통해서 소통을 해야한다. 그렇게 나온것이 HTTP서버이다. const http = require('http'); // http 모듈 생성 http.createServer((req, res) => { // http 서버 생성 res.write('Hello server!') // html태그 전송 res.end('Hello hanamDeveloper!') // 서버 종료와 동시에 html태그 전송 }).listen(8080, () => { // 8080 port로 생성 console.log('포트 8080에서 서버 대기 중입니다.') }) 우..