Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Matteo Giordano committed Feb 23, 2017
0 parents commit 39db332
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
npm-debug.log
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
npm-debug.log
15 changes: 15 additions & 0 deletions Dockerfile
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" ]
15 changes: 15 additions & 0 deletions package.json
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"
}
28 changes: 28 additions & 0 deletions server.js
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);
});

0 comments on commit 39db332

Please sign in to comment.