Toggle navigation
Toggle navigation
This project
Loading...
Sign in
은승우
/
LINEBOT
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
은승우
2019-12-05 19:07:55 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
c7e998856f9760f91e1dd21e09b93b883d663e6a
c7e99885
1 parent
b5ac88c8
Update app.js
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
9 deletions
app.js
app.js
View file @
c7e9988
...
...
@@ -5,7 +5,7 @@ var request = require('request');
var
https
=
require
(
'https'
);
var
http
=
require
(
'http'
);
var
mime
=
require
(
'mime-types'
);
var
png
=
require
(
'png-js'
);
var
fs
=
require
(
"fs"
);
var
httpsOptions
=
{
...
...
@@ -89,7 +89,17 @@ async function handleEvent(event) {
await
stream
.
on
(
'data'
,
(
chunk
)
=>
{
console
.
log
(
typeof
(
chunk
));
fs
.
writeFileSync
(
"./photo/1.png"
,
chunk
);
var
cheerio
=
require
(
'cheerio'
);
var
PNG
=
require
(
'png-js'
);
var
myimage
=
new
PNG
(
"./photo/1.png"
);
var
width
=
myimage
.
width
;
var
height
=
myimage
.
height
;
myimage
.
decode
(
function
(
pixels
)
{
//Pixels is a 1D array containing pixel data
var
cheerio
=
require
(
'cheerio'
);
var
uriBase
=
'https://koreacentral.api.cognitive.microsoft.com/vision/v2.1/ocr'
;
var
options
=
{
uri
:
uriBase
,
...
...
@@ -101,14 +111,11 @@ async function handleEvent(event) {
'Content-Type'
:
'application/json'
,
'Ocp-Apim-Subscription-Key'
:
'979dc5d63344438fa4701c62feebb7dc'
},
body
:
fs
.
readFileSync
(
"./photo/1.png"
)
body
:
myimage
};
app
.
get
(
'/photo'
,(
req
,
res
)
=>
{
res
.
send
(
chunk
+
"png"
);
})
/*
request
.
post
(
options
,
function
(
error
,
response
,
body
)
{
var data=body;
var
data
=
options
.
body
;
console
.
log
(
data
);
var
text
=
''
;
while
(
data
.
indexOf
(
'text\\'
)
!=-
1
)
...
...
@@ -140,8 +147,10 @@ async function handleEvent(event) {
}
client
.
replyMessage
(
event
.
replyToken
,
result
).
then
(
resolve
).
catch
(
reject
);
});
});
*/
});
});
...
...
Please
register
or
login
to post a comment