조아혜

del file

1 -var client_id = 'v3M4wjolGLkrvNA3GUIW';
2 -var client_secret = 'fKF6vjkWhE';
3 -var fs = require('fs');
4 -var request = require('request');
5 -const path = require('path');
6 -var express = require('express');
7 -var app = express();
8 -var domain = "www.osstest237.ml"
9 -const sslport = 23023;
10 -const HTTPS = require('https');
11 -
12 -exports.imgtodata = function(dir){
13 - var api_url = 'https://openapi.naver.com/v1/vision/face'; // 얼굴 감지
14 -
15 - var _formData = {
16 - image:'image',
17 - image: fs.createReadStream(path.join(__dirname, dir)) // FILE 이름
18 - };
19 -
20 - request.post(
21 - { url:api_url,
22 - formData:_formData,
23 - headers: {'X-Naver-Client-Id':client_id,
24 - 'X-Naver-Client-Secret': client_secret}
25 - }, (err,response,body) =>{
26 - console.log(response.statusCode); // 200
27 - //console.log(response.headers['content-type'])
28 -
29 - data=JSON.parse(body);
30 - gender=data.faces[0].gender.value;
31 - emotion=data.faces[0].emotion.value
32 -
33 - console.log(gender);
34 - console.log(emotion);
35 -
36 - //return {gender:gender,emotion:emotion};
37 - });
38 - }
39 -
40 - try {
41 - const option = {
42 - ca: fs.readFileSync('/etc/letsencrypt/live/' + domain +'/fullchain.pem'),
43 - key: fs.readFileSync(path.resolve(process.cwd(), '/etc/letsencrypt/live/' + domain +'/privkey.pem'), 'utf8').toString(),
44 - cert: fs.readFileSync(path.resolve(process.cwd(), '/etc/letsencrypt/live/' + domain +'/cert.pem'), 'utf8').toString(),
45 - };
46 - HTTPS.createServer(option, app).listen(sslport, () => {
47 - console.log(`[HTTPS] Server is started on port ${sslport}`);
48 - });
49 - } catch (error) {
50 - console.log('[HTTPS] HTTPS 오류가 발생하였습니다. HTTPS 서버는 실행되지 않습니다.');
51 - console.log(error);
52 -}
53 -
54 -//imgtodata('./test3.jpg');
...\ No newline at end of file ...\ No newline at end of file