Skip to content

Instantly share code, notes, and snippets.

View bnerd's full-sized avatar
💭
Go with the flow.

Bernd Hansen bnerd

💭
Go with the flow.
View GitHub Profile
@bnerd
bnerd / index.js
Created March 10, 2012 11:54
Serve large files with Node.js
var libpath = require('path');
var http = require('http');
var fs = require('fs');
var url = require('url');
var bind_port = 8001;
var path = "/path/to/your/base_directory/";
http.createServer(function (request, response) {
var uri = url.parse(request.url).pathname;
var filename = libpath.join(path, uri);