Showing
2 changed files
with
45 additions
and
36 deletions
... | @@ -15,47 +15,52 @@ app.post('/hook', function (req, res) { | ... | @@ -15,47 +15,52 @@ app.post('/hook', function (req, res) { |
15 | 15 | ||
16 | var eventObj = req.body.events[0]; | 16 | var eventObj = req.body.events[0]; |
17 | var source = eventObj.source; | 17 | var source = eventObj.source; |
18 | + | ||
18 | var message = eventObj.message; | 19 | var message = eventObj.message; |
19 | - | 20 | + var pystring; |
20 | 21 | ||
21 | - var spawn = require('child_process').spawn; | 22 | + const spawn = require("child_process").spawn; |
22 | - var process = spawn('pyhton3', ["./basic.py", eventObj.message.text]); | 23 | + const process = spawn("python", ["basic.py", eventObj.message.text]); |
23 | - process.stdout.on('data', function(data){ | 24 | + const Callback = (data) => { |
24 | - console.log(data.toString()); | 25 | + console.log("Data :", data.toString()); |
25 | - }) | 26 | + pystring = data.toString(); |
27 | + // request log | ||
28 | + console.log('======================', new Date() ,'======================'); | ||
29 | + console.log('[request]', req.body); | ||
30 | + console.log('[request source] ', eventObj.source); | ||
31 | + console.log('[request message]', eventObj.message); | ||
26 | 32 | ||
33 | + request.post( | ||
34 | + { | ||
35 | + url: TARGET_URL, | ||
36 | + headers: { | ||
37 | + 'Authorization': `Bearer ${TOKEN}` | ||
38 | + }, | ||
39 | + json: { | ||
40 | + "replyToken":eventObj.replyToken, | ||
41 | + "messages":[ | ||
42 | + { | ||
43 | + "type":"text", | ||
44 | + "text":pystring | ||
45 | + }, | ||
46 | + { | ||
47 | + "type":"text", | ||
48 | + "text":"May I help you?" | ||
49 | + } | ||
50 | + ] | ||
51 | + } | ||
52 | + },(error, response, body) => { | ||
53 | + console.log(body) | ||
54 | + }); | ||
55 | + | ||
27 | 56 | ||
28 | - // request log | 57 | + res.sendStatus(200); |
29 | - console.log('======================', new Date() ,'======================'); | 58 | + |
30 | - console.log('[request]', req.body); | 59 | + }; |
31 | - console.log('[request source] ', eventObj.source); | 60 | + process.stdout.on("data", Callback); |
32 | - console.log('[request message]', eventObj.message); | ||
33 | 61 | ||
34 | - request.post( | ||
35 | - { | ||
36 | - url: TARGET_URL, | ||
37 | - headers: { | ||
38 | - 'Authorization': `Bearer ${TOKEN}` | ||
39 | - }, | ||
40 | - json: { | ||
41 | - "replyToken":eventObj.replyToken, | ||
42 | - "messages":[ | ||
43 | - { | ||
44 | - "type":"text", | ||
45 | - "text":"Hello" | ||
46 | - }, | ||
47 | - { | ||
48 | - "type":"text", | ||
49 | - "text":"May I help you?" | ||
50 | - } | ||
51 | - ] | ||
52 | - } | ||
53 | - },(error, response, body) => { | ||
54 | - console.log(body) | ||
55 | - }); | ||
56 | - | ||
57 | 62 | ||
58 | - res.sendStatus(200); | 63 | + |
59 | }); | 64 | }); |
60 | 65 | ||
61 | try { | 66 | try { | ... | ... |
... | @@ -2,6 +2,7 @@ import FinanceDataReader as fdr | ... | @@ -2,6 +2,7 @@ import FinanceDataReader as fdr |
2 | import pandas as pd | 2 | import pandas as pd |
3 | import sys | 3 | import sys |
4 | 4 | ||
5 | + | ||
5 | def basicinform(input): | 6 | def basicinform(input): |
6 | stocks = pd.read_csv('stockcodename.csv', index_col=0) | 7 | stocks = pd.read_csv('stockcodename.csv', index_col=0) |
7 | symbol = '' | 8 | symbol = '' |
... | @@ -23,5 +24,8 @@ def basicinform(input): | ... | @@ -23,5 +24,8 @@ def basicinform(input): |
23 | } | 24 | } |
24 | return value | 25 | return value |
25 | 26 | ||
27 | + | ||
28 | +# print(basicinform('삼성전자')) | ||
29 | + | ||
26 | args = sys.argv | 30 | args = sys.argv |
27 | -print(basicinform(sys.args[1])) | 31 | +print(basicinform(args[1])) | ... | ... |
-
Please register or login to post a comment