[Node.js] express 라우팅 기초(get 요청, post 요청)
·
nodejs
이번엔 get, post 요청에 대한 응답하는 법을 알아보려고 한다. # get 요청get 요청은 주로 데이터를 요청해서 보여줄 때 사용한다. const express = require('express'); const app = express(); const port = 3000; // HTTP get 요청 app.get('/', (req,res) => { res.send('home') }) // 로컬호스트 포트번호 설정 app.listen(port, ()=>{ console.log(`포트 번호 : 3000`); });/ 은 루트경로를 의미한다. 일반적인 페이지의 home을 담당한다 해당 url로 get 요청을 하게되면 home텍스트가 화면에 출력된다. 다른 페이지에 요청const express = re..
[node.js] express 시작
·
nodejs
이번엔 node.js 의 프레임워크인 express에 대해 공부해봤다. https://expressjs.com/ko/ Express - Node.js 웹 애플리케이션 프레임워크Node.js를 위한 빠르고 개방적인 간결한 웹 프레임워크 $ npm install express --saveexpressjs.com프레임워크와 라이브러리의 차이점은 제어의 주체라고 알고있다. express는 프레임워크기 때문에 express에서 주는 틀대로 사용해야 앱이 잘 동작하게 할 수 있다. express에 사용방법에 대해 알아보자 일단 터미널에서 express 패키지를 설치한 후 npm i express js 를 작성 const express = require('express'); const app = express(); ..
[node.js] 어느 국가의 언어인지 추측하기
·
해보기
사용 모듈 https://github.com/wooorm/franc GitHub - wooorm/franc: Natural language detection Natural language detection. Contribute to wooorm/franc development by creating an account on GitHub. github.com 사람이 알아볼수 있게 바로 판독은 힘들고 문자열을 받아 ISO 코드로 변환해준다 https://github.com/adlawson/nodejs-langs GitHub - adlawson/nodejs-langs: ISO 639-1/2/3 Language codes with English and local names ISO 639-1/2/3 Language..
[node.js] install, init, node_modules, package.json
·
nodejs
NPM Node.js의 패키지를 관리할 수 있는 도구 참고 사이트) https://www.npmjs.com/ npm Bring the best of open source to you, your team, and your company Relied upon by more than 17 million developers worldwide, npm is committed to making JavaScript development elegant, productive, and safe. The free npm Registry has become the center of Java www.npmjs.com #npm install npm i -g 패키지명 // 전역설치 npm i 패키지명 // 지역설치 배포한 파일을 ..
[node.js] module.exports
·
nodejs
다른 파일에 있는 것을 가져다 쓸려면 어떻게 해야할까? https://jjaong34.tistory.com/50 [node.js] process, file system(fs) https://nodejs.org/docs/latest-v19.x/api/ Index | Node.js v19.9.0 Documentationnodejs.org노드 문서 node 에 진입 후 process를 입력하면 버전과 정보에 대해서 나온다. 그 중에 argv 라는 것을 알아보자 process.argv 를 콘솔 jjaong34.tistory.com 저번시간에 node에서 fs와 process를 써봤는데 const fs = require('fs') fs는 내부 모듈이기 때문에 바로 사용이 가능했다. 외부 모듈을 가져올때 예를 들면..
[node.js] process, file system(fs)
·
nodejs
https://nodejs.org/docs/latest-v19.x/api/ Index | Node.js v19.9.0 Documentationnodejs.org노드 문서 node 에 진입 후 process를 입력하면 버전과 정보에 대해서 나온다. 그 중에 argv 라는 것을 알아보자 process.argv 를 콘솔에 찍어보면console.log(process.argv); 이렇게 나오는데 마치 함수의 인수를 나타내는 argument와 비슷하다 create.js 뒤에 추가로 입력하면 인수로 전달가능하다 들어온 값은 인덱스로 표현되고 0과 1번은 노드와 해당파일을 나타내니 2번 부터 사용하면 된다 node create.js test이러면 test라는 인수가 전달되고 process.argv[2]로 test를 받..
개발짜옹
'node.js' 태그의 글 목록 (3 Page)