mirror of
https://git.sleeping.town/mirrors/foxy-moxy
synced 2024-11-24 04:57:42 +00:00
Merge pull request #10 from Patreon/luke---set-content-length
Set content length.
This commit is contained in:
commit
c982800b1a
1 changed files with 9 additions and 3 deletions
12
server.js
12
server.js
|
@ -45,24 +45,30 @@ app.get('/', function(req, res) {
|
|||
var width = 400;
|
||||
var seed = uuid();
|
||||
var canvas = composeImage(width, width, seed);
|
||||
var buffer = canvas.toBuffer();
|
||||
res.set('Content-length', buffer.length);
|
||||
res.type('png');
|
||||
res.end(canvas.toBuffer(), 'binary');
|
||||
res.end(buffer, 'binary');
|
||||
});
|
||||
|
||||
app.get('/:width', function(req, res) {
|
||||
var width = parseInt(req.params.width) || 400;
|
||||
var seed = uuid();
|
||||
var canvas = composeImage(width, width, seed);
|
||||
var buffer = canvas.toBuffer();
|
||||
res.set('Content-length', buffer.length);
|
||||
res.type('png');
|
||||
res.end(canvas.toBuffer(), 'binary');
|
||||
res.end(buffer, 'binary');
|
||||
});
|
||||
|
||||
app.get('/:width/:seed', function(req, res) {
|
||||
var width = parseInt(req.params.width) || 400;
|
||||
var seed = sanitize(req.params.seed) || uuid();
|
||||
var canvas = composeImage(width, width, seed);
|
||||
var buffer = canvas.toBuffer();
|
||||
res.set('Content-length', buffer.length);
|
||||
res.type('png');
|
||||
res.end(canvas.toBuffer(), 'binary');
|
||||
res.end(buffer, 'binary');
|
||||
});
|
||||
|
||||
app.listen(process.env.PORT || 3000);
|
||||
|
|
Loading…
Reference in a new issue