박하늘

app.js : reply updated

......@@ -15,47 +15,52 @@ app.post('/hook', function (req, res) {
var eventObj = req.body.events[0];
var source = eventObj.source;
var message = eventObj.message;
var pystring;
var spawn = require('child_process').spawn;
var process = spawn('pyhton3', ["./basic.py", eventObj.message.text]);
process.stdout.on('data', function(data){
console.log(data.toString());
})
const spawn = require("child_process").spawn;
const process = spawn("python", ["basic.py", eventObj.message.text]);
const Callback = (data) => {
console.log("Data :", data.toString());
pystring = data.toString();
// request log
console.log('======================', new Date() ,'======================');
console.log('[request]', req.body);
console.log('[request source] ', eventObj.source);
console.log('[request message]', eventObj.message);
request.post(
{
url: TARGET_URL,
headers: {
'Authorization': `Bearer ${TOKEN}`
},
json: {
"replyToken":eventObj.replyToken,
"messages":[
{
"type":"text",
"text":pystring
},
{
"type":"text",
"text":"May I help you?"
}
]
}
},(error, response, body) => {
console.log(body)
});
// request log
console.log('======================', new Date() ,'======================');
console.log('[request]', req.body);
console.log('[request source] ', eventObj.source);
console.log('[request message]', eventObj.message);
res.sendStatus(200);
};
process.stdout.on("data", Callback);
request.post(
{
url: TARGET_URL,
headers: {
'Authorization': `Bearer ${TOKEN}`
},
json: {
"replyToken":eventObj.replyToken,
"messages":[
{
"type":"text",
"text":"Hello"
},
{
"type":"text",
"text":"May I help you?"
}
]
}
},(error, response, body) => {
console.log(body)
});
res.sendStatus(200);
});
try {
......
......@@ -2,6 +2,7 @@ import FinanceDataReader as fdr
import pandas as pd
import sys
def basicinform(input):
stocks = pd.read_csv('stockcodename.csv', index_col=0)
symbol = ''
......@@ -23,5 +24,8 @@ def basicinform(input):
}
return value
# print(basicinform('삼성전자'))
args = sys.argv
print(basicinform(sys.args[1]))
print(basicinform(args[1]))
......