장재훈

modify app.js

...@@ -7,50 +7,47 @@ const apiRouter = express.Router(); ...@@ -7,50 +7,47 @@ const apiRouter = express.Router();
7 7
8 app.use(logger('dev', {})); 8 app.use(logger('dev', {}));
9 app.use(bodyParser.json()); 9 app.use(bodyParser.json());
10 +app.use(bodyParser.urlencoded({
11 + extended: true
12 +}));
13 +
10 app.use('/api', apiRouter); 14 app.use('/api', apiRouter);
11 15
12 -apiRouter.post('/champion', function(req,res) { 16 +apiRouter.post('/sayHello', function(req, res) {
13 - res.send("Hello,world!"); 17 + const responseBody = {
14 - /* 18 + version: "2.0",
15 - const responsebody = { 19 + template: {
16 - 20 + outputs: [
17 - "version": "2.0", 21 + {
18 - "template": { 22 + simpleText: {
19 - "outputs": [ 23 + text: "hello I'm Ryan"
20 - { 24 + }
21 - "basicCard": { 25 + }
22 - "title": "보물상자", 26 + ]
23 - "description": "보물상자 안에는 뭐가 있을까", 27 + }
24 - "thumbnail": { 28 + };
25 - "imageUrl": "http://k.kakaocdn.net/dn/83BvP/bl20duRC1Q1/lj3JUcmrzC53YIjNDkqbWK/i_6piz1p.jpg" 29 +
26 - }, 30 + res.status(200).send(responseBody);
27 - "profile": { 31 +});
28 - "imageUrl": "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcT4BJ9LU4Ikr_EvZLmijfcjzQKMRCJ2bO3A8SVKNuQ78zu2KOqM", 32 +
29 - "nickname": "보물상자" 33 +apiRouter.post('/showHello', function(req, res) {
30 - }, 34 + console.log(req.body);
31 - "social": { 35 +
32 - "like": 1238, 36 + const responseBody = {
33 - "comment": 8, 37 + version: "2.0",
34 - "share": 780 38 + template: {
35 - }, 39 + outputs: [
36 - "buttons": [ 40 + {
37 - { 41 + simpleImage: {
38 - "action": "message", 42 + imageUrl: "https://t1.daumcdn.net/friends/prod/category/M001_friends_ryan2.jpg",
39 - "label": "열어보기", 43 + altText: "hello I'm Ryan"
40 - "messageText": "짜잔! 우리가 찾던 보물입니다" 44 + }
41 - }, 45 + }
42 - { 46 + ]
43 - "action": "webLink", 47 + }
44 - "label": "구경하기", 48 + };
45 - "webLinkUrl": "https://e.kakao.com/t/hello-ryan" 49 +
46 - } 50 + res.status(200).send(responseBody);
47 - ]
48 - }
49 - }
50 - ]
51 - }
52 - };
53 - */
54 }); 51 });
55 /* 52 /*
56 const fs = require('fs'); 53 const fs = require('fs');
...@@ -68,6 +65,7 @@ app.post('/champion',function(req,res){ ...@@ -68,6 +65,7 @@ app.post('/champion',function(req,res){
68 }) 65 })
69 66
70 67
68 +
71 app.get('/', function(req, res){ 69 app.get('/', function(req, res){
72 res.send('Hello, World!'); 70 res.send('Hello, World!');
73 }) 71 })
...@@ -84,10 +82,7 @@ app.get('/users/:userId/books/:bookId', function(req, res){ ...@@ -84,10 +82,7 @@ app.get('/users/:userId/books/:bookId', function(req, res){
84 console.log(req.params.bookId) 82 console.log(req.params.bookId)
85 res.send(req.params); 83 res.send(req.params);
86 }) 84 })
87 -
88 -var server = app.listen(23023, function(){
89 - var host = server.address().address
90 - var port = server.address().port
91 - console.log("Example app listening at https://tft-helper.tk", host, port)
92 -})
93 -*/
...\ No newline at end of file ...\ No newline at end of file
85 +*/
86 +app.listen(3000, function(){
87 + console.log("Example skill server listening on port 3000!");
88 +});
......
This diff is collapsed. Click to expand it.