Toggle navigation
Toggle navigation
This project
Loading...
Sign in
김대연
/
emergency_room_ChatBot
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
root
2022-11-28 01:48:15 +0000
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
d5e6365aef22ba4cb6e458f3cc0c2f16ce888a03
d5e6365a
1 parent
b94e514f
update app.js
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
13 deletions
app.js
app.js
View file @
d5e6365
...
...
@@ -6,24 +6,21 @@ const TOKEN = 'YK56BfHFgpILrxRk1FZrdcouFguf5CBA5qxM3zfDH6N9jR/cfPxVdK1P9vZHAk69m
const
fs
=
require
(
'fs'
);
const
path
=
require
(
'path'
);
const
HTTPS
=
require
(
'https'
);
const
domain
=
"
ec2-18-215-162-16.compute-1.amazonaws.com
"
const
domain
=
"
2019102158.oss2022chatbot.tk
"
const
sslport
=
23023
;
const
bodyParser
=
require
(
'body-parser'
);
const
app
=
express
();
console
.
log
(
Address
.
getAddress
(
'석수동길'
));
app
.
use
(
bodyParser
.
json
());
app
.
post
(
'/hook'
,
function
(
req
,
res
)
{
var
eventObj
=
req
.
body
.
events
[
0
];
var
source
=
eventObj
.
source
;
var
message
=
eventObj
.
message
;
//
var source = eventObj.source;
//
var message = eventObj.message;
// request log
console
.
log
(
'======================'
,
new
Date
()
,
'======================'
);
console
.
log
(
'[request]'
,
req
.
body
);
console
.
log
(
'[request source] '
,
eventObj
.
source
);
console
.
log
(
'[request message]'
,
eventObj
.
message
);
console
.
log
((
Address
.
getAddress
(
'석수동길'
)).
road_address
.
address_name
)
request
.
post
(
{
url
:
TARGET_URL
,
...
...
@@ -31,17 +28,18 @@ app.post('/hook', function (req, res) {
'Authorization'
:
`Bearer
${
TOKEN
}
`
},
json
:
{
"replyToken"
:
eventObj
.
replyToken
,
"replyToken"
:
eventObj
.
replyToken
,
//eventObj.replyToken
"messages"
:[
{
"type"
:
"text"
,
"text"
:
"Hello, user"
"text"
:
address
},
{
"type"
:
"text"
,
"text"
:
"
May I help you
?"
"text"
:
"
맞나요
?"
}
]
],
"status"
:
1
}
},(
error
,
response
,
body
)
=>
{
console
.
log
(
body
)
...
...
@@ -49,10 +47,17 @@ app.post('/hook', function (req, res) {
res
.
sendStatus
(
200
);
});
try
{
const
option
=
{
key
:
fs
.
readFileSync
(
'./rootca.key'
,
'utf8'
),
cert
:
fs
.
readFileSync
(
'./rootca.crt'
,
'utf8'
),
ca
:
fs
.
readFileSync
(
'/etc/letsencrypt/live/'
+
domain
+
'/fullchain.pem'
),
key
:
fs
.
readFileSync
(
path
.
resolve
(
process
.
cwd
(),
'/etc/letsencrypt/live/'
+
domain
+
'/privkey.pem'
),
'utf8'
).
toString
(),
cert
:
fs
.
readFileSync
(
path
.
resolve
(
process
.
cwd
(),
'/etc/letsencrypt/live/'
+
domain
+
'/cert.pem'
),
'utf8'
).
toString
(),
};
HTTPS
.
createServer
(
option
,
app
).
listen
(
sslport
,
()
=>
{
...
...
Please
register
or
login
to post a comment