Cute Happy Ghost
본문 바로가기
Front/Html, css,jsp

20201110_33 server...

by JENN_tech7 2020. 11. 10.
728x90
SMALL

dir 디렉토리 알 수 있음

cd .\누르고 tab하면 디렉토리 이동\

그다음 npm init누르면 package.json이 생성됨

C:\Users\user1\Frontend>dir
 C 드라이브의 볼륨: 교육생_OS
 볼륨 일련 번호: 00CB-C4D0

 C:\Users\user1\Frontend 디렉터리

2020-11-10  오전 09:41    <DIR>          .
2020-11-10  오전 09:41    <DIR>          ..
2020-11-09  오전 10:47    <DIR>          20201109
2020-11-10  오전 09:42    <DIR>          20201110
2020-11-09  오후 02:13             3,331 README.md
               1개 파일               3,331 바이트
               4개 디렉터리  262,623,424,512 바이트 남음


C:\Users\user1\Frontend>cd .\20201110\

C:\Users\user1\Frontend\20201110> npm init
This 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 fields
and exactly what they do.

Use `npm install <pkg>` afterwards to install a package and
save it as a dependency in the package.json file.

Press ^C at any time to quit.
package name: (20201110)
version: (1.0.0)
description:
entry point: (index.js)
test command:
git repository:
keywords:
author:
license: (ISC)
About to write to C:\Users\user1\Frontend\20201110\package.json:

{
  "name": "20201110",
  "version": "1.0.0",
  "description": "사용자 입력을 받는 부분",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC"
}


Is this OK? (yes)

npm init 로드프로젝트로 만든다는 것

그 결과 패키지.json

 

 

그 다음 npm install express치면 설치완

 

 

 

 

const express = require('express')
const app = express()
const port = 6600

app.post('/login', (req, res) => {
    console.log('Connection has been established.')
})

app.listen(port, () =>{
    console.log(`Server is running on ${port}`);
})

c+a+n 실행

c+a+m 서버닫는키

뭐 이런 게 떴구요

 

node .\해서 app.js로 이동 , enter

 

 

 

  • 서버....(모르겠음)
const express = require('express')
const app = express()
const port = 6600

// 현재 디렉토리에 있는 파일(static file)을 서빙
app.use(express.static('.'))

const bp = require('body-parser')
app.use(bp.json())
app.use(bp.urlencoded({extended: true}))

// /login으로 post 요청 시 값 그대로 출력
app.post('/login', (req, res) => {
    console.log('Connection has been established.')
    console.log(req.body)
})

// 서버 실행
app.listen(port, () => {
    console.log(`Server is running on ${port}`);
})

 

728x90
LIST

'Front > Html, css,jsp' 카테고리의 다른 글

20201111_34 레이아웃 실습  (0) 2020.11.11
20201111_ 34 사각형  (0) 2020.11.11
20201110_ 33 css  (0) 2020.11.10
20201110_33 로그인화면만들어보기  (0) 2020.11.10
20201109_ 33 html기본  (0) 2020.11.09

댓글