Toggle navigation
Toggle navigation
This project
Loading...
Sign in
이종규
/
chatbot_project
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
JKL
2021-12-01 21:08:26 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
9ed8c05b303ec77a74ce6bbd15f52f0c3df4c195
9ed8c05b
1 parent
b31602f1
Server_Update
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
18 deletions
app.js
app.js
View file @
9ed8c05
const
express
=
require
(
'express'
);
const
cheerio
=
require
(
'cheerio'
);
const
fs
=
require
(
'fs'
);
const
path
=
require
(
'path'
);
const
HTTPS
=
require
(
'https'
);
const
domain
=
"2020105107.osschatbot.cf"
const
sslport
=
23023
;
const
app
=
express
();
app
.
use
(
express
.
urlencoded
({
extended
:
false
}));
app
.
use
(
express
.
json
());
app
.
get
(
'/keyboard'
,
(
req
,
res
)
=>
{
const
data
=
{
'type'
:
'text'
}
res
.
json
(
data
);
});
app
.
post
(
'/message'
,
(
req
,
res
)
=>
{
const
question
=
req
.
body
.
userRequest
.
utterance
;
const
goMain
=
'처음으로'
;
var
data
;
if
(
question
==
=
'테스트'
)
{
const
data
=
{
if
(
question
==
"서울캠퍼스"
)
{
data
=
{
'version'
:
'2.0'
,
'template'
:
{
'outputs'
:
[{
'simpleText'
:
{
'text'
:
'테스트'
}
}],
'quickReplies'
:
[{
'label'
:
goMain
,
'action'
:
'message'
,
'messageText'
:
goMain
}]
'outputs'
:
[{
'simpleImage'
:
{
'imageUrl'
:
"https://coop.khu.ac.kr/wp-content/uploads/2021/11/20211129-1301x2048.png"
,
'altText'
:
"서울캠퍼스 식단입니다."
}
}],
'quickReplies'
:
[{
'label'
:
goMain
,
'action'
:
'message'
,
'messageText'
:
goMain
}]
}
}
}
res
.
json
(
data
);
});
app
.
listen
(
23023
,
()
=>
console
.
log
(
'node on 23023'
));
\ No newline at end of file
try
{
const
option
=
{
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
,
()
=>
{
console
.
log
(
`[HTTPS] Server is started on port
${
sslport
}
`
);
});
}
catch
(
error
)
{
console
.
log
(
'[HTTPS] HTTPS 오류가 발생하였습니다. HTTPS 서버는 실행되지 않습니다.'
);
console
.
log
(
error
);
}
...
...
Please
register
or
login
to post a comment