Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
31 |
Tags
- pl/sql
- table scan
- 에자일 모형
- plsql
- Bandit Level 5
- 커맨드공부
- 프로토타입 모형
- 시스템 파악
- CSS
- 시스템 파악 정리
- Law of Demeter
- 인증서만료에러
- java.sql.SQLRecoverableException
- vue
- 폭포수 모형
- 변수명 짓는법
- mysql 튜닝
- was버그
- avax.net.ssl.SSLHandshakeException:
- 스크럼기법
- 디미터 법칙
- was SQLRecoverableException
- 나선형 모형
- 명령어공부
- OpenAPI
- springboot
- 클린코드
- Bandit Level 6
- SQLRecoverableException
- Bandit Level 6 → Level 7
Archives
- Today
- Total
개발햄비
[node.js] CRUD : read 기능 만들기 본문
fs.readFile('/etc/passwd', (err, data) => { if (err) throw err; console.log(data); });
var http = require('http');
var fs = require('fs');
var url = require('url');
var qs = require('querystring')
function templatHTML(tatle,list,body,data){
return \`
<title>WEB1 - ${tatle}</title>
<meta charset="utf-8">
# [Web](/)
${list}
${data}
${body}
<p>
</p>
\`;
}
function makeFlieList(filelist){
var list = '
';
var i = 0
while (i< filelist.length) {
list = list + \`<li><a href="/?id=${filelist\[i\]}">${filelist\[i\]}</a></li>\`;
i= i + 1;
}
list = list + '
';
return list
};
function makeInfo(tatle,filelist,description,data){
var list = makeFlieList(filelist,description);
var templat = templatHTML(tatle,list,\`
## ${tatle}
${description}\`,data);
return templat;
}
var app = http.createServer(function(request,response){
var \_url = request.url;
var queryData = url.parse(\_url,true).query;
var pathname = url.parse(\_url,true).pathname;
if(pathname === '/'){
if(queryData.id === undefined){
fs.readdir('./data',function( error,filelist){
var templat = makeInfo('welcome',filelist,'hello node.js','<a href="/create">create</a>');
response.writeHead(200);
response.end(templat);
})
}else{
fs.readdir('./data',function( error,filelist){
fs.readFile(\`data/${queryData.id}\`,'utf8',function(err,description){
var tatle = queryData.id;
var templat = makeInfo(tatle,filelist,description,
\`<a href="/create">create</a>
<a href="/update?id=${tatle}">update</a>
<form action="/delete\_process" method="post">
<input type="hidden" name="id" value ="${tatle}">
<input type="submit" value = "delete">
</form>
\`);
response.writeHead(200);
response.end(templat);
});
});
}
}
'개발 > node.js' 카테고리의 다른 글
[node.js] CRUD : create 기능 만들기 (0) | 2019.08.31 |
---|---|
[node.js] module 사용법 (0) | 2019.08.31 |
[node.js] 페이스북 + node 챗봇 만들기 (4) | 2019.04.07 |
[node.js] node.js CRUD기능 예제 (0) | 2019.02.20 |
[node.js] 입력정보 보안 처리 (0) | 2019.02.02 |