Merge pull request #1 from Patreon/luke---make-server-work

Luke   make server work
This commit is contained in:
Luke Davis 2016-12-15 12:23:04 -08:00 committed by GitHub
commit f1d0973ab6
3 changed files with 159 additions and 159 deletions

2
.gitignore vendored
View file

@ -1 +1,3 @@
node_modules/
.DS_Store
images/*

0
images/.placeholder Normal file
View file

View file

@ -173,32 +173,30 @@ var radial = function(ctx,width,height){
var Canvas = require('canvas');
var express = require('express');
var fs = require('fs');
var app = express();
app.use(express.static(__dirname + '/images'));
app.get('/:width', function(req, res) {
var width = Math.min(1000, Math.max(0, parseInt(req.params.width) || 500));
var height = width;
var Canvas = require('canvas')
, Image = Canvas.Image
, canvas = new Canvas(width, height)
, ctx = canvas.getContext('2d');
var width = 200;
var height = 200;
var Canvas = require('canvas');
var Image = Canvas.Image;
var canvas = new Canvas(width, height);
var ctx = canvas.getContext('2d');
textIcon(canvas, width, height);
res.send(canvas.toDataURL());
/*
var img = new Buffer(canvas.toDataURL(), 'base64');
console.log(img.length);
var fileName = "fox" + Math.floor(Math.random() * 10000) + ".png";
res.writeHead(200, {
'Content-Type': 'image/png',
'Content-Length': img.length
fs.writeFile(__dirname + '/images/' + fileName, canvas.toBuffer(), function(err) {
console.log('error', err);
});
res.end();
*/
console.log(fileName);
res.redirect(301, fileName);
});