Created
May 18, 2019 17:21
-
-
Save takedasan/b6104dbf372a700a0f9854655fc199f7 to your computer and use it in GitHub Desktop.
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
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