Skip to content

Instantly share code, notes, and snippets.

@diem1
Created February 25, 2016 17:46
Show Gist options
  • Save diem1/517df41ca1ba4da44fc5 to your computer and use it in GitHub Desktop.
Save diem1/517df41ca1ba4da44fc5 to your computer and use it in GitHub Desktop.
NodeJS Get text form file to browser
http = require('http')
fs = require('fs')
readableStream = fs.createReadStream('file.txt')
data = ''
http.Server((res, req) ->
readableStream.on 'data', (chunk) ->
data += chunk
return
readableStream.on 'end', ->
req.end(data)
return
).listen 3333
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment