Toggle navigation
Toggle navigation
This project
Loading...
Sign in
박하늘
/
stock_chatbot
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
박하늘
2021-05-30 23:24:22 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
72a8ad480249044cb2e32d281ad30462a8dfa57c
72a8ad48
1 parent
31683682
app.js : reply updated
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
36 deletions
server/app.js
server/basic.py
server/app.js
View file @
72a8ad4
...
...
@@ -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
{
...
...
server/basic.py
View file @
72a8ad4
...
...
@@ -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
]))
...
...
Please
register
or
login
to post a comment