-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Matteo Giordano
committed
Feb 23, 2017
0 parents
commit 39db332
Showing
5 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules | ||
npm-debug.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules | ||
npm-debug.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
FROM node:boron | ||
|
||
# Create app directory | ||
RUN mkdir -p /usr/src/app | ||
WORKDIR /usr/src/app | ||
|
||
# Install app dependencies | ||
COPY package.json /usr/src/app/ | ||
RUN npm install | ||
|
||
# Bundle app source | ||
COPY . /usr/src/app | ||
|
||
EXPOSE 3000 | ||
CMD [ "npm", "start" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"name": "vivace", | ||
"version": "1.0.0", | ||
"description": "Extract prominent colors from an image", | ||
"main": "server.js", | ||
"dependencies": { | ||
"express": "^4.14.1", | ||
"node-vibrant": "^2.1.2" | ||
}, | ||
"scripts": { | ||
"start": "node server.js" | ||
}, | ||
"author": "Matteo Giordano <[email protected]>", | ||
"license": "MIT" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
var http = require('http'); | ||
var express = require('express'); | ||
var Vibrant = require('node-vibrant'); | ||
|
||
var app = express(); | ||
var server = http.createServer(app); | ||
|
||
app.get('/', function (req, res) { | ||
var imgUrl = req.query.imgUrl; | ||
|
||
if (imgUrl == undefined) { | ||
res.status(400).send('Missing `imgUrl` parameter'); | ||
return; | ||
} | ||
|
||
Vibrant.from(imgUrl).getPalette(function (err, palette) { | ||
if (err != null) { | ||
res.status(500).send(err.toString()); | ||
} | ||
|
||
res.json(palette); | ||
}); | ||
}); | ||
|
||
server.listen(process.env.PORT || 3000, process.env.IP || "0.0.0.0", function () { | ||
var addr = server.address(); | ||
console.log("Vivace listening at", addr.address + ":" + addr.port); | ||
}); |