Showing
1 changed file
with
26 additions
and
10 deletions
1 | const express = require('express'); | 1 | const express = require('express'); |
2 | +const cheerio = require('cheerio'); | ||
3 | +const fs = require('fs'); | ||
4 | +const path = require('path'); | ||
5 | +const HTTPS = require('https'); | ||
6 | +const domain = "2020105107.osschatbot.cf" | ||
7 | +const sslport = 23023; | ||
2 | const app = express(); | 8 | const app = express(); |
3 | 9 | ||
4 | app.use(express.urlencoded({ extended: false })); | 10 | app.use(express.urlencoded({ extended: false })); |
5 | app.use(express.json()); | 11 | app.use(express.json()); |
6 | 12 | ||
7 | -app.get('/keyboard', (req, res) => { | ||
8 | - const data = {'type': 'text'} | ||
9 | - res.json(data); | ||
10 | -}); | ||
11 | - | ||
12 | app.post('/message', (req, res) => { | 13 | app.post('/message', (req, res) => { |
13 | const question = req.body.userRequest.utterance; | 14 | const question = req.body.userRequest.utterance; |
14 | const goMain = '처음으로'; | 15 | const goMain = '처음으로'; |
16 | + var data; | ||
15 | 17 | ||
16 | - if (question === '테스트') { | 18 | + if (question == "서울캠퍼스") { |
17 | - const data = { | 19 | + data = { |
18 | 'version': '2.0', | 20 | 'version': '2.0', |
19 | 'template': { | 21 | 'template': { |
20 | 'outputs': [{ | 22 | 'outputs': [{ |
21 | - 'simpleText': { | 23 | + 'simpleImage': { |
22 | - 'text': '테스트' | 24 | + 'imageUrl': "https://coop.khu.ac.kr/wp-content/uploads/2021/11/20211129-1301x2048.png", |
25 | + 'altText' : "서울캠퍼스 식단입니다." | ||
23 | } | 26 | } |
24 | }], | 27 | }], |
25 | 'quickReplies': [{ | 28 | 'quickReplies': [{ |
... | @@ -33,4 +36,17 @@ app.post('/message', (req, res) => { | ... | @@ -33,4 +36,17 @@ app.post('/message', (req, res) => { |
33 | res.json(data); | 36 | res.json(data); |
34 | }); | 37 | }); |
35 | 38 | ||
36 | -app.listen(23023, () => console.log('node on 23023')); | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
39 | +try { | ||
40 | + const option = { | ||
41 | + ca: fs.readFileSync('/etc/letsencrypt/live/' + domain +'/fullchain.pem'), | ||
42 | + key: fs.readFileSync(path.resolve(process.cwd(), '/etc/letsencrypt/live/' + domain +'/privkey.pem'), 'utf8').toString(), | ||
43 | + cert: fs.readFileSync(path.resolve(process.cwd(), '/etc/letsencrypt/live/' + domain +'/cert.pem'), 'utf8').toString(), | ||
44 | + }; | ||
45 | + | ||
46 | + HTTPS.createServer(option, app).listen(sslport, () => { | ||
47 | + console.log(`[HTTPS] Server is started on port ${sslport}`); | ||
48 | + }); | ||
49 | +} catch (error) { | ||
50 | + console.log('[HTTPS] HTTPS 오류가 발생하였습니다. HTTPS 서버는 실행되지 않습니다.'); | ||
51 | + console.log(error); | ||
52 | +} | ... | ... |
-
Please register or login to post a comment