-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
28 lines (16 loc) · 725 Bytes
/
Copy pathserver.js
File metadata and controls
28 lines (16 loc) · 725 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
var fs = require('fs');
var http = require('http');
var myReadStream = fs.createReadStream(__dirname + '/readMe.txt', 'utf8'); //myReadStream inherits events because of fs
var myWriteStream = fs.createWriteStream(__dirname + '/writeMe.txt');
myReadStream.on('data', function(chunk){ // data is event
console.log('New chunk received');
myWriteStream.write(chunk);
});
// var http = require('http');
// var server = http.createServer(function(req, res){
// console.log('Request was made ' + req.url);
// res.writeHead(200, {'Content-Type': 'text/plain'}); //res.writeHead(status, content-type)
// res.end('Yo dawgs!');
// });
// server.listen(3000, '127.0.0.1');
// console.log('Listening now on port 3000!');