공정훈

Add test_code

1 +./app/node_mdules
...\ No newline at end of file ...\ No newline at end of file
1 +const express = require('express');
2 +const app = express();
3 +const bodyParser = require('body-parser');
4 +
5 +app.use(bodyParser.urlencoded({extended: false}));
6 +app.use(bodyParse.json());
7 +
8 +app.post('/api/sayHello', (req, res) => {
9 + const responseBody = { //skill response
10 + version: "2.0", //version 필수
11 + template: { // template 필수
12 + outputs: [
13 + {
14 + simpleText: {
15 + text: "hello I'm Ryan"
16 + }
17 + }
18 + ]
19 + }
20 + };
21 + res.status(200).send(responseBody);
22 +});
23 +
24 +app.post('/api/showHello', (req, res) => {
25 + console.log(req.body);
26 + const responseBody = {
27 + version: "2.0",
28 + template: {
29 + outputs: [
30 + {
31 + simpleImage: {
32 + imageUrl: "https://t1.daumcdn.net/friends/prod/category/M001_friends_ryan2.jpg",
33 + altText: "hello I'm Ryan"
34 + }
35 + }
36 + ]
37 + }
38 + };
39 + res.status(200).send(responseBody);
40 +});
41 +
42 +app.post('/message', (req, res) => {
43 + const question = req.body.userRequest.utterance;
44 + if (question === 'test') {
45 + const responseBody = {
46 + version: "2.0",
47 + template: {
48 + outputs: [
49 + {
50 + simpleText: {
51 + text: "text..."
52 + }
53 + }
54 + ],
55 + quickReplies: [
56 + {
57 + label: 'go main',
58 + action: 'message',
59 + messageText: 'go main'
60 + }
61 + ]
62 + }
63 + };
64 + res.status(200).send(responseBody);
65 + }
66 +})
67 +
68 +var server = app.listen(3000);
...\ No newline at end of file ...\ No newline at end of file
This diff is collapsed. Click to expand it.
1 +{
2 + "dependencies": {
3 + "express": "^4.18.1"
4 + }
5 +}