Skip to content

Instantly share code, notes, and snippets.

@cuipengfei
Created December 14, 2013 06:17
Show Gist options
  • Save cuipengfei/7956178 to your computer and use it in GitHub Desktop.
Save cuipengfei/7956178 to your computer and use it in GitHub Desktop.
learn you node http file server
var http = require('http')
var fs = require('fs')
var port = process.argv[2]
var fileName = process.argv[3]
http.createServer(function (request, response) {
fs.createReadStream(fileName).pipe(response)
}).listen(port)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment