반응형
SMALL
- GET 요청
- /62 방문하면,
- 메세지 띄우기.
app.get('/62',function(요청, 응답){
응답.send('서버 스터디 페이지입니다.');
}};
- 서버 재실행 자동화하기
- 서버를 자동으로 on&off
- nodemon 사용
- Nodemon 노드가 디렉터리를 감시하고 있다가 파일이 수정되면 자동으로 애플리케이션을 재시작하는 확장 모듈
- 설치방법
// 방법1. nodemon //
npm install -g nodemon
// 방법2. yarn //
yarn add global nodemon
- 실행
nodemon server.js
- 오류시
- powershell 실행
executionpolicy
set-executionpolicy unrestricted
y
- HTML 파일 보내기
- sendFile(보낼파일경로)
// /index.html 템플릿 생성 //
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>My test page</title>
</head>
<body>
<h4>케이의 마케팅 노트입니다.</h4>
<p>홈입니다.</p>
</body>
</html>
// GET 요청 //
app.get('/',function(요청, 응답){
응답.sendFile(__dirname + '/index.html')
}};
ref:
반응형
LIST
'웹(web) > 서버' 카테고리의 다른 글
라이브러리로 HTML/CSS 쉽게 생성하기 (w. Bootstrap) (0) | 2023.01.02 |
---|---|
서버(Server) 띄우기 (기본셋팅 & 테스트) (0) | 2023.01.01 |
서버(Server)란 무엇일까? (기초개념 & 설치) (0) | 2023.01.01 |