일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- InfluxDB
- influxdb 설치
- g++ 업데이트
- 백준
- 정규식 컴파일
- 1697
- 정규식 활용
- snmp
- snmp test
- c++ 정규식
- CentOS7
- gcc regex
- telegraf
- centos pyhon 설치
- python subprocess
- c3 초
- grafana dashboard
- c3 축 없애기
- selinux port 등록
- semanage
- python popen
- c3 second
- python os
- linux시간으로 변경
- subporcess path
- regex_search
- c3 step graph
- 정규식 문자열 출력
- c3 축 가리기
- gcc 업데이트
- Today
- Total
목록분류 전체보기 (560)
리셋 되지 말자
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/cpaKCD/btqJCuiXeNe/Hz1A9BMT0KlPd7Fpzkxhnk/img.png)
Session cookie 웹 브라우저가 켜있는 상태에서 유효하고, 껏다가 다시 키면 사라진다. Permanent cookie 웹 브라우저를 껏다가 켜도 유효하다. Permanent cookie 사용하기 cookie.js var http = require('http'); var cookie = require('cookie'); var app = http.createServer(function (request, response) { if (request.headers.cookie != undefined) { console.log(cookie.parse(request.headers.cookie)); } response.writeHead(200, { 'Set-Cookie': ['yummy_cookie=choc..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/4DfiW/btqJCuJMQU4/TVk2CD5FJz55zcFclokFT1/img.png)
쿠키 읽기 cookie.js var http = require('http'); var app = http.createServer(function(request, response){ console.log(request.headers.cookie); response.writeHead(200, { 'Set-Cookie' : ['yummy_cookie=choco', 'tasty_cooke=strawberry'] }); response.end('hello world'); }); app.listen(80); request.headers에 있는 cookie를 출력해본다. 쿠키가 출력되는 것을 확인할 수 있다. 쿠키를 다루는 npm 모듈 (www.npmjs.com/package/cookie) 설치한다. cookie.j..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/HqweK/btqJvS6HiUR/exqmYx592VE4foddwdvED1/img.png)
쿠키 생성 전 var http = require('http'); var app = http.createServer(function(request, response){ // response.writeHead(200, { // 'Set-Cookie' : ['yummy_cookie=choco', 'tasty_cooke=strawberry'] // }); response.end('hello world'); }); app.listen(80); 이렇게 간단히 nodejs 웹서버를 구성하고, 실행한 뒤 개발자 도구의 Network 탭을 확인해본다. 별다를게 없는 get방식의 요청과 응답이다. cookie.js var http = require('http'); var app = http.createServer(func..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/ccUqB4/btqJtlAamVy/9JOsmnamBDqsPKccWHpdDk/img.png)
fetch API 기본 사용법 웹서버를 열어서 fetch.html을 연다. (아파치 톰캣을 이용했다.) fetch.html 'html'이라는 파일을 서버에 요청하고, 응답이 끝나면 그 응답이 콜백함수에 담겨서 'text'라는 인자에 파일의 내용이 담겨온다 라고 일단 이해하고 넘어가자 fetch.html파일이 있는 경로에 html이라는 파일이 존재한다. 내용은 아래와 같다. html html is ... 접속화면 fetch 버튼 클릭 fetch API의 원리(요청과 응답) fetch('html') client가 'html'이라는 파일을 서버로부터 달라고 웹브라우저에게 요청한다. 네트워크 탭을 확인하면, html 파일을 가져온 것을 확인할 수 있다. .then은 fetch('html')이 끝나면 즉, 요청을..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/bk9XOb/btqJltsnKhH/Eo3KT6ki0t2voXnKK7bf3k/img.png)
보안 (expressjs.com/en/advanced/best-practice-security.html) 예전 버전을 사용하지 마라 TSL (https, SSL)을 사용해라 helmet을 사용해라 npm install --save helmet helmet 설치 var helmet = require('helmet') app.use(helmet()); helmet 사용 cookie를 안전하게 사용해라 방문자를 식별하기 위해 cookie가 사용된다. (인증에서 핵심으로 사용됨) dependency를 안전하게 관리해라 npm audit 위 명령어를 사용하면 검사를 해준다. 아래 캡처사진은 위의 명령어를 실행한 결과이다. 아래에 snyk라는것도 있는데 이건 생략
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/bUvQL4/btqJjvcVgEc/LjSMWE6nzASHP5FsuEvvk1/img.png)
안되던 주소 express의 클린 url 체계 방식으로 form이나 링크 이동을 클린 url로, 즉 상세 페이지 보기에서 'localhost/page/:pageId' 로 이동하도록 했는데, 글 생성 및 update도 'localhost/page/create'와 'localhost/page/update'로 하고 싶었는데 변경하면 안되었다. 안된 이유는 미들웨어 'localhost/page/:pageId'를 처리하는데, /page/create를 입력해버리면 pageId인 상세페이지 보기로 인식하기 때문이다. 해결방법은 간단한데, '/page/create'를 처리하는 미들웨어를 '/page/:pageId'를 처리하는 미들웨어보다 위쪽에 두는 것이다. 링크의 이동하는 경로와 미들웨어의 순서를 변경하여 해결했다...
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/bQLki9/btqJijcBJZ3/rtNNym5u5JVakJuZ2kGcR0/img.png)
404 not found 처리 (expressjs.com/ko/starter/faq.html)이 사이트에 따라서, 미들웨어의 마지막에 아래의 코드를 추가한다. app.use(function(req, res, next) { res.status(404).send('Sorry cant find that!'); }); 미들웨어는 순차적으로 실행되기 때문에, 해당 미들웨어를 만났다는 것은 이전 미들웨어들에 대응하는 요청을 처리하지 못했다는것을 뜻하므로 마지막에 선언해준다. 나머지 오류 처리 app.use(function (err, req, res, next) { console.error(err.stack) res.status(500).send('Something broke!') }) 404에러 처리 미들웨어 다음..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/bdlnhS/btqJnE1kGsz/X4eStGzGnuCULrK6KSdsHk/img.png)
미들웨어 종류 (expressjs.com/en/guide/using-middleware.html)페이지에서 아래와 같이 미들웨어의 종류를 확인할 수 있다. 미들웨어 실행 순서 app.get('/user/:id', function (req, res, next) { // if the user ID is 0, skip to the next route if (req.params.id === '0') next('route') // otherwise pass the control to the next middleware function in this stack else next() }, function (req, res, next) { // send a regular response res.send('regular..