Created
August 22, 2016 19:40
-
-
Save rbadillap/30b583e44cd541622472e59e92a8dbbf to your computer and use it in GitHub Desktop.
Serve a 1px gif using express
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
const app = require('express')() | |
app.get('/gif', (req, res) => { | |
const data = [ | |
0x47,0x49, 0x46,0x38, 0x39,0x61, 0x01,0x00, 0x01,0x00, 0x80,0x00, 0x00,0xFF, 0xFF,0xFF, | |
0x00,0x00, 0x00,0x21, 0xf9,0x04, 0x04,0x00, 0x00,0x00, 0x00,0x2c, 0x00,0x00, 0x00,0x00, | |
0x01,0x00, 0x01,0x00, 0x00,0x02, 0x02,0x44, 0x01,0x00, 0x3b | |
] | |
return res | |
.set('Content-Type', 'image/gif') | |
.set('Content-Length', data.length) | |
.status(200) | |
.send(new Buffer(data)) | |
}) | |
app.listen(3000 || process.env.PORT) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment