-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathserver.js
More file actions
executable file
·89 lines (73 loc) · 2.4 KB
/
server.js
File metadata and controls
executable file
·89 lines (73 loc) · 2.4 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
var express = require('express');
var fs = require('fs');
var http = require('http');
//lodash
var _ = require('lodash');
//"hound" module contains both client-side ("Hound") and server-side ("HoundNode") parts of SDK
var hound = require('hound').HoundNode;
//flickr API
/*
var flickr = require("flickrapi"),
flickrOptions = {
api_key: "076a4c69f691e1440ae67d1858beb9c0",
secret: "99ad15f675ce0830"
};
flickr.tokenOnly(flickrOptions, function(error, flickr) {
// we can now use "flickr" as our API object,
// but we can only call public methods and access public data
});*/
/*
var Flickr = require("flickrapi"),
flickrOptions = {
api_key: "076a4c69f691e1440ae67d1858beb9c0",
secret: "99ad15f675ce0830"
};
var flickrOptions = {
api_key: "076a4c69f691e1440ae67d1858beb9c0",
secret: "99ad15f675ce0830",
user_id: "74214425@N02",
access_token: "72157663895266375-dc6ba94aa1dcd2d5",
access_token_secret: "59e615eeb7aecb8b"
}*/
var Flickr = require("flickrapi"),
flickrOptions = {
api_key: "076a4c69f691e1440ae67d1858beb9c0",
secret: "99ad15f675ce0830",
user_id: "74214425@N02",
access_token: "72157663895266375-dc6ba94aa1dcd2d5",
access_token_secret: "59e615eeb7aecb8b"
};
Flickr.authenticate(flickrOptions, function(error, flickr) {
// we can now use "flickr" as our API object
});
/*
var flickr = new Flickr({
api_key: "076a4c69f691e1440ae67d1858beb9c0"
});*/
//parse arguments
var argv = require('minimist')(process.argv.slice(2));
//config file
var configFile = argv.config || 'config';
var config = require(__dirname + '/' + configFile);
//express app
var app = express();
var publicFolder = argv.public || 'public';
app.use(express.static(__dirname + '/' + publicFolder));
//authenticates voice search requests
app.get('/voiceSearchAuth', hound.createVoiceAuthHandler({
clientId: config.clientId,
clientKey: config.clientKey
}));
//sends the request to Hound backend with authentication headers
app.get('/textSearchProxy', hound.createTextProxyHandler({
clientId: config.clientId,
clientKey: config.clientKey
}));
//ssl credentials
//https server
var httpServer = http.createServer(app);
var port = config.port || 3000;
httpServer.listen(port, function() {
console.log("HTTPS server running on port", port);
console.log("Open https://localhost:" + port, "in the browser to view the Web SDK demo");
});