Toggle navigation
Toggle navigation
This project
Loading...
Sign in
방승일
/
find_mbti_bot
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
김성욱
2022-05-23 20:14:20 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
3997eaf0e3d5b6cc02482f6d2e99bfaa892e04c0
3997eaf0
1 parent
ba14b864
Update test_code
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
59 deletions
app/app.js
app/app.js
View file @
3997eaf
const
express
=
require
(
'express'
);
const
app
=
express
();
const
logger
=
require
(
'morgan'
);
const
bodyParser
=
require
(
'body-parser'
);
app
.
use
(
bodyParser
.
urlencoded
({
extended
:
false
}));
app
.
use
(
bodyParse
.
json
());
const
apiRouter
=
express
.
Router
();
app
.
post
(
'/api/sayHello'
,
(
req
,
res
)
=>
{
const
responseBody
=
{
//skill response
version
:
"2.0"
,
//version 필수
template
:
{
// template 필수
outputs
:
[
{
simpleText
:
{
text
:
"hello I'm Ryan"
}
}
]
}
};
res
.
status
(
200
).
send
(
responseBody
);
});
app
.
use
(
logger
(
'dev'
,
{}));
app
.
use
(
bodyParser
.
json
());
app
.
use
(
bodyParser
.
urlencoded
({
extended
:
true
}));
app
.
post
(
'/api/showHello'
,
(
req
,
res
)
=>
{
console
.
log
(
req
.
body
);
const
responseBody
=
{
version
:
"2.0"
,
template
:
{
outputs
:
[
{
simpleImage
:
{
imageUrl
:
"https://t1.daumcdn.net/friends/prod/category/M001_friends_ryan2.jpg"
,
altText
:
"hello I'm Ryan"
}
}
]
}
};
res
.
status
(
200
).
send
(
responseBody
);
});
app
.
use
(
'/api'
,
apiRouter
);
app
.
post
(
'/message'
,
(
req
,
res
)
=>
{
const
question
=
req
.
body
.
userRequest
.
utterance
;
if
(
question
===
'test'
)
{
const
responseBody
=
{
version
:
"2.0"
,
template
:
{
outputs
:
[
{
simpleText
:
{
text
:
"text..."
}
}
],
quickReplies
:
[
{
label
:
'go main'
,
action
:
'message'
,
messageText
:
'go main'
}
]
}
};
res
.
status
(
200
).
send
(
responseBody
);
apiRouter
.
post
(
'/sayHello'
,
function
(
req
,
res
)
{
const
responseBody
=
{
version
:
"2.0"
,
template
:
{
outputs
:
[
{
simpleText
:
{
text
:
"MBTI 검사 챗봇입니다!"
}
}
]
}
})
};
res
.
status
(
200
).
send
(
responseBody
);
});
var
server
=
app
.
listen
(
3000
);
\ No newline at end of file
app
.
listen
((
process
.
env
.
PORT
||
3000
),
function
()
{
console
.
log
(
'Example skill server listening on port 3000!'
);
});
\ No newline at end of file
...
...
Please
register
or
login
to post a comment