EC2 Default User

fix app.js to use fileread.py file

......@@ -3,15 +3,15 @@ var count = 0;
var choosen = new Array();
var express = require('express');
const request = require('request');
const TARGET_URL = '타겟 URL'
const TOKEN = '토큰'
const PAPAGO_URL = '파파고 URL'
const PAPAGO_ID = '파파고 ID'
const PAPAGO_SECRET = '파파고 시크릿'
const fs = require('fs');
const TARGET_URL = 'https://api.line.me/v2/bot/message/reply'
const TOKEN = 'Ur8nbk2bQAc9KavLSSJv0uzlKWCxCBnOJOKyqbRS1mMHWgJlEOPfb7v+X1DDEHocUmhU7KnPFN+KHt5S3SYd5QmF42aTeQpW2gDVTjyqty1Tn+p6QqEhI/uSz659PBHwczEYn0Plx+akfCNHDPJRpAdB04t89/1O/w1cDnyilFU='
const PAPAGO_URL = 'https://openapi.naver.com/v1/papago/n2mt'
const PAPAGO_ID = '1Z83W3lUGLqnNbrDAk8A'
const PAPAGO_SECRET = 'ST7ElRPFPP'
var fs = require('fs');
const path = require('path');
const HTTPS = require('https');
const domain = "도메인"
const domain = "2021105602.osschatbot2022.tk"
const sslport = 23023;
const bodyParser = require('body-parser');
const res = require('express/lib/response');
......@@ -35,7 +35,7 @@ app.post('/hook', function (req, res) {
count++;
start_msg(eventObj.replyToken, eventObj.message.text);
}else if(eventObj.message.text == 'y' && count ==1)
}else if(eventObj.message.text === 'y' && count ==1)
{
opt_1(eventObj.replyToken, eventObj.message.text);
}else if((eventObj.message.text === '1' || eventObj.message.text === '2' || eventObj.message.text === '3' || eventObj.message.text == '4' || eventObj.message.texts == '5') && count ==1)
......@@ -74,9 +74,16 @@ app.post('/hook', function (req, res) {
}else{
err(eventObj.replyToken);
}
const spawn = require('child_process').spawn;
const result = spawn('python', ['/home/ec2-user/menu_recommand_webpage-1/CHATBOT/fileread_practice.py', '/home/ec2-user/menu_recommand_webpage-1/CHATBOT/1_person.txt', '/home/ec2-user/menu_recommand_webpage-1/CHATBOT/water.txt']);
result.stdout.on('data', function (data) {
console.log(data.toString());
});
result.stderr.on('data', function (data) {
console.log(data.toString());
});
res.sendStatus(200);
});
async function start_msg(replyToken, message) {
......@@ -358,8 +365,8 @@ async function load_map(replyToken)
"replyToken": replyToken,
"messages": [
{
"type": "herf",
"href": "file:///C:/Users/pnr02/Desktop/opensource_project/selectWestern.html"
"type": "text",
"text": "https://www.daleseo.com/js-sleep/"
}
]
}
......@@ -390,6 +397,21 @@ async function err(replyToken)
});
}
async function read_file(dir, arr)
{
await fs.readFile(dir, function(err, data) {
if(err) throw err;
arr = data.toString().split("\n");
n1=arr;
});
}
function sleep(ms) {
const wakeUpTime = Date.now() + ms;
while (Date.now() < wakeUpTime) {}
}
try {
const option = {
ca: fs.readFileSync('/etc/letsencrypt/live/' + domain + '/fullchain.pem'),
......