[4주차 03] express

개발냥이·2025년 2월 11일

데브코스

목록 보기
12/75

express

공식 사이트에서는 Node.js를 위한 빠르고 의견 일치가 없는 미니멀리스트 웹 프레임워크이라고 한다

즉 NodeJS를 빠르게 사용하게 도와주는 프레임워크이다

  • http 모듈과 비교해보기

    • http 모듈 사용

      		```javascript
      		let http = require('http'); 
      
      		const onRequest = (req, res) => {
      	res.writeHead(200, {'content-type': 'text/html'});
      	res.write('NodeJS');
      	res.end();
      		};
      
      		http.createServer(onRequest).listen(3000);
      		```
    • express 사용

      			const express = require('express');
      			const app = express(); //서버를 담아둠
      
      			app.get('/', function (req, res) {
      		res.send('hello express');
      			});
      
      			app.listen(3000);
      			```

extra) 객체 , JSON

  • 객체

    • 속성을 가진 독립적인 객체

    • 데이터를 한번에 모아둔 것

    • 속성 (property) : 키와 값 사이의 연결관계

  • JSON (JavaScript Object Notation) : JS 객체 표기법

	let person = {
    	name : 'bin',
      	age : 20
    }
  • person이라는 객체에 name, age 속성이 있다
profile
웹 개발자가 되고픈

0개의 댓글