Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@takedasan
Created May 18, 2019 17:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save takedasan/b6104dbf372a700a0f9854655fc199f7 to your computer and use it in GitHub Desktop.
Save takedasan/b6104dbf372a700a0f9854655fc199f7 to your computer and use it in GitHub Desktop.
fs = require("fs");
http = require("http");
url = require("url");
Jimp = require("jimp");
http.createServer(function (req, res) {
var request = url.parse(req.url, true);
var action = request.pathname;
if(action == "/image.bmp") {
// なぜかタイムアウトして画像が設定できないんですけど!!!
var img = fs.readFileSync('./image.bmp', {encoding: null});
var buffer = new Buffer.from(img);
console.log(buffer);
res.statusMessage = "OK";
res.writeHead(200, {'Content-Type': 'image/bmp' });
res.end(img);
} else {
res.statusMessage = "OK";
res.writeHead(200, { 'Content-Type': 'application/json' });
res.end('{"template":"template1","title":"@takeda_san","subtitle":"Programer","bodytext":"nanimo shitenai noni Code Card ga kawatta","icon":"duke","backgroundColor":"white"}');
}
}).listen(80);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment