Created
February 25, 2016 17:46
-
-
Save diem1/517df41ca1ba4da44fc5 to your computer and use it in GitHub Desktop.
NodeJS Get text form file to browser
This file contains hidden or 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
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