var express    = require('express'),
    fs   = require('fs'),
    path = require('path'),
    app  = express(),
    file = 'public/file.txt',
    pipe = require('pipe-io');

app.get('/', function(req, res) {
  res.sendFile(path.join(__dirname, 'public/index.html'), function (err) {
    if (err) {
      console.log(err);
      res.status(err.status).end();
    }
    else {
      console.log('Sent');
      res.status(200);
    }
  });
  
});

app.get('/file', function (req, res) {
  var readStream = fs.createReadStream(file);
  readStream.on('open', function () {
    // This just pipes the read stream to the response object (which goes to the client)
    readStream.pipe(res);
  });
})

app.put('/file', function (req, res) {
  req.pipe(fs.createWriteStream(file, {'flags': 'a'}));
  req.on('end', console.log.bind(console, 'done'));
  res.end()

});
console.log('Server is listeting 3000 port. Enjoy :).')
app.listen(3000);
@@ -536,16 +536,114 @@
 adStream
+%0A    .on('error', function(e) %7B%0A      console.log('problem with request: ' + e.message);%0A  %7D)%0A    
 .on('ope
@@ -656,24 +656,24 @@
 nction () %7B%0A
-
     // This 
@@ -885,16 +885,114 @@
 );%0A  req
+%0A    .on('error', function(e) %7B%0A      console.log('problem with request: ' + e.message);%0A  %7D)%0A    
 .on('end
@@ -1042,21 +1042,21 @@
 s.end()%0A
-%0A
 %7D);%0A
+%0A
 console.
@@ -1075,17 +1075,17 @@
 is liste
-t
+n
 ing 3000

add errors handling for second get and put requests