Showing
1 changed file
with
20 additions
and
15 deletions
| ... | @@ -2,29 +2,26 @@ | ... | @@ -2,29 +2,26 @@ |
| 2 | // 모듈 불러오기 | 2 | // 모듈 불러오기 |
| 3 | var express = require('express'); | 3 | var express = require('express'); |
| 4 | var http = require('http'); | 4 | var http = require('http'); |
| 5 | -var bodyParser = require('body-parser') | 5 | +var bodyParser = require('body-parser'); |
| 6 | 6 | ||
| 7 | -var hostname = '210.89.181.183'; | ||
| 8 | -var port = 9090; | ||
| 9 | var app = express(); // express 객체 저장 | 7 | var app = express(); // express 객체 저장 |
| 10 | 8 | ||
| 11 | -app.set('port', process.env.PORT || 9090); | ||
| 12 | -app.set('host', process.env.HOST || '210.89.181.183') | ||
| 13 | - | ||
| 14 | //body-parser 미들웨어 사용 | 9 | //body-parser 미들웨어 사용 |
| 15 | app.use(bodyParser.urlencoded({extended: false})); | 10 | app.use(bodyParser.urlencoded({extended: false})); |
| 16 | app.use(bodyParser.json()); | 11 | app.use(bodyParser.json()); |
| 17 | 12 | ||
| 18 | // http://서버주소/keyboard | 13 | // http://서버주소/keyboard |
| 19 | app.get('/keyboard', function(req,res){ | 14 | app.get('/keyboard', function(req,res){ |
| 20 | - var data = {'type' : 'buttons', 'buttons' : ['일본', '한국', '미국계'] }; | 15 | + var data = { |
| 16 | + 'type' : 'buttons', | ||
| 17 | + 'buttons' : ['일본', '한국', '미국계']}; | ||
| 21 | res.json(data); | 18 | res.json(data); |
| 22 | - } | 19 | + |
| 23 | -); | 20 | +}); |
| 24 | 21 | ||
| 25 | //9090포트로 서버 접속 | 22 | //9090포트로 서버 접속 |
| 26 | -http.createServer(app).listen(app.get('port'), app.get('host'), () => { | 23 | +http.createServer(app).listen(8080, () => { |
| 27 | - console.log('Server running at https://${hostname}:%{port}/'); | 24 | + console.log('Server running..'); |
| 28 | }); | 25 | }); |
| 29 | 26 | ||
| 30 | 27 | ||
| ... | @@ -37,7 +34,7 @@ app.post('/message', function(req,res){ | ... | @@ -37,7 +34,7 @@ app.post('/message', function(req,res){ |
| 37 | var send = {}; | 34 | var send = {}; |
| 38 | 35 | ||
| 39 | switch(msg){ | 36 | switch(msg){ |
| 40 | - case 'reol' : | 37 | + case 'Reol' : |
| 41 | send = { | 38 | send = { |
| 42 | 'message' : { | 39 | 'message' : { |
| 43 | 'text' : 'Reol', | 40 | 'text' : 'Reol', |
| ... | @@ -55,8 +52,17 @@ app.post('/message', function(req,res){ | ... | @@ -55,8 +52,17 @@ app.post('/message', function(req,res){ |
| 55 | 52 | ||
| 56 | }; | 53 | }; |
| 57 | break; | 54 | break; |
| 58 | - case '가수' : | 55 | + case '일본' : |
| 59 | - send = {}; | 56 | + send = { |
| 57 | + 'message' : { | ||
| 58 | + 'text' : '등록된 가수 목록입니다.' | ||
| 59 | + }, | ||
| 60 | + keyboard : { | ||
| 61 | + 'type' : 'buttons', | ||
| 62 | + 'buttons' : ['Reol', '米津玄師', 'yanaginagi', 'ヨルシカ', 'ダズビ'] | ||
| 63 | + } | ||
| 64 | + | ||
| 65 | + }; | ||
| 60 | break; | 66 | break; |
| 61 | case 'C' : | 67 | case 'C' : |
| 62 | send = {}; | 68 | send = {}; |
| ... | @@ -65,6 +71,5 @@ app.post('/message', function(req,res){ | ... | @@ -65,6 +71,5 @@ app.post('/message', function(req,res){ |
| 65 | send = {} ; | 71 | send = {} ; |
| 66 | break; | 72 | break; |
| 67 | } | 73 | } |
| 68 | - | ||
| 69 | res.json(send); | 74 | res.json(send); |
| 70 | }) | 75 | }) |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
-
Please register or login to post a comment