-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
51 lines (41 loc) · 1.1 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
var http = require("http");
var server = http.createServer(function (req, res) {
if(req.url == '/'){
const Clarifai = require('clarifai');
var testtags = [];
var i, count = 0;
function getTags(image_url){
const app = new Clarifai.App({
apiKey:
});
app.models.predict(Clarifai.GENERAL_MODEL, image_url).then(
function abc(response) {
var tags = response.outputs[0].data.concepts.map(data => data.name);
for(i = 0; i <= 8 ; i++){
testtags.push(tags[i]);
}
var res = "#"+testtags.join(" #");
console.log(res);
var fs = require("fs");
var fileContent = res;
fs.writeFile("./sample.txt", fileContent, (err) => {
if (err) {
console.error(err);
return;
};
console.log("File has been created");
});
},
function(err) {
console.error(err);
}
);
}
tags = getTags('https://nairobinews.nation.co.ke/wp-content/uploads/2017/08/Meru-accident.jpg');
res.end('<strong>End the Prgm</strong>');
}
console.log(req.url);
});
server.listen(3082, function(){
console.log('listening to 3082');
});