Skip to content

Instantly share code, notes, and snippets.

View craftgear's full-sized avatar
🏠
Working from home

Captain Emo craftgear

🏠
Working from home
  • self-employed
  • Japan
View GitHub Profile
@bnoordhuis
bnoordhuis / gist:702695
Created November 16, 2010 23:01
node.js + sendfile = file serving++
http = require('http');
fs = require('fs');
fd = fs.openSync(__filename, 'r');
size = fs.fstatSync(fd).size;
server = http.createServer(function(req, res) {
res.writeHead(200, {
'Content-Length': size,
'Content-Type': 'text/plain'