Showing
2 changed files
with
19 additions
and
10 deletions
... | @@ -15,16 +15,15 @@ app.post('/hook', function (req, res) { | ... | @@ -15,16 +15,15 @@ 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 | - var message = eventObj.message; | ||
19 | - | ||
20 | - | ||
21 | - var spawn = require('child_process').spawn; | ||
22 | - var process = spawn('pyhton3', ["./basic.py", eventObj.message.text]); | ||
23 | - process.stdout.on('data', function(data){ | ||
24 | - console.log(data.toString()); | ||
25 | - }) | ||
26 | 18 | ||
19 | + var message = eventObj.message; | ||
20 | + var pystring; | ||
27 | 21 | ||
22 | + const spawn = require("child_process").spawn; | ||
23 | + const process = spawn("python", ["basic.py", eventObj.message.text]); | ||
24 | + const Callback = (data) => { | ||
25 | + console.log("Data :", data.toString()); | ||
26 | + pystring = data.toString(); | ||
28 | // request log | 27 | // request log |
29 | console.log('======================', new Date() ,'======================'); | 28 | console.log('======================', new Date() ,'======================'); |
30 | console.log('[request]', req.body); | 29 | console.log('[request]', req.body); |
... | @@ -42,7 +41,7 @@ app.post('/hook', function (req, res) { | ... | @@ -42,7 +41,7 @@ app.post('/hook', function (req, res) { |
42 | "messages":[ | 41 | "messages":[ |
43 | { | 42 | { |
44 | "type":"text", | 43 | "type":"text", |
45 | - "text":"Hello" | 44 | + "text":pystring |
46 | }, | 45 | }, |
47 | { | 46 | { |
48 | "type":"text", | 47 | "type":"text", |
... | @@ -56,6 +55,12 @@ app.post('/hook', function (req, res) { | ... | @@ -56,6 +55,12 @@ app.post('/hook', function (req, res) { |
56 | 55 | ||
57 | 56 | ||
58 | res.sendStatus(200); | 57 | res.sendStatus(200); |
58 | + | ||
59 | + }; | ||
60 | + process.stdout.on("data", Callback); | ||
61 | + | ||
62 | + | ||
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