Develpment/Node.js
-
static 디렉토리 설정 (express)Develpment/Node.js 2020. 9. 13. 21:32
1. static 디렉토리 설정 * express, nodemon 사용. * main.html 수정 (12번 라인 추가) 123456789101112131415 main.html main page hello node main html Colored by Color Scriptercs * main.js : 404 not found 에러 발생 * app.js 수정 ( 10번 라인 추가 ) 12345678910111213141516var express = require('express') // express 모듈 로드 var app = express() // 3000 포트로 웹서버 실행app.listen(3000, function() { console.log("start! express server on po..
-
URL Routing 처리Develpment/Node.js 2020. 9. 13. 21:32
1. URL Roution 처리 * express, nodemon 사용 * app.js 파일 1234567891011121314var express = require('express') // express 모듈 로드 var app = express() // 3000 포트로 웹서버 실행app.listen(3000, function() { console.log("start! express server on port 3000!")}); app.get('/', function(req, res) { //res.send('hello get!') res.sendFile(__dirname + "/public/main.html")}) Colored by Color Scriptercs * __dirname : 현 프로젝트..
-
간단한 web server (express)Develpment/Node.js 2020. 9. 13. 21:31
1. express ( http://expressjs.com/ko/starter/installing.html ) * express 설치$ npm install express --save * save 옵션으로 인해 package.json 에 추가 1234567891011121314{ "name": "section01", "version": "1.0.0", "description": "npm project", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "author": "", "license": "ISC", "dependencies": { "express": "^4.15.3" }}Colore..
-
NPM Project 생성하기Develpment/Node.js 2020. 9. 13. 21:31
1. NPM Project 시작 $ npm init 123456789101112131415161718192021222324252627282930313233343536This utility will walk you through creating a package.json file.It only covers the most common items, and tries to guess sensible defaults. See `npm help json` for definitive documentation on these fieldsand exactly what they do. Use `npm install --save` afterwards to install a package andsave it as a dep..