
  var http = require('http');
  var fs = require('fs');
  var url = require('url');
  var path = require('path');
  var socket_io = require('socket.io');
  var mime = require('mime');

  module.exports = {
    create: function(){
      var httpServer = http.createServer(function(req, res){
        var location = url.parse(req.url, true, true);
        var filename = path.normalize(__dirname + '/../appcp' + location.pathname);

        var isIndex = location.pathname == '/';
        if (isIndex)
          filename += 'index.html';

        if (fs.existsSync(filename))
        {
          var fileContent = fs.readFileSync(filename);

          if (isIndex)
            fileContent = String(fileContent).replace(/<\/body>/i, '<script>window.appcp_server = true</script></body>');

          res.writeHead(200, { 'Content-Type': mime.lookup(filename, 'text/plain') });
          res.end(fileContent);
        }
        else
        {
          res.writeHead(404);
          res.end(filename + ' not found');
        }
      });

      httpServer.listen(8001, function(){
        console.log('app control server created at port', 8001);
      });

      var io = socket_io.listen(httpServer);
      io.disable('log');

      io.sockets.on('connection', function(socket){
        socket.on('message', function(message){
          io.sockets.emit('message', message);
        });
      });
    }
  }

@@ -451,47 +451,126 @@
     
-var isIndex = location.pathname == '/';
+if (fs.existsSync(filename))%0D%0A        %7B%0D%0A          var stat = fs.statSync(filename);%0D%0A          var isIndex = false;%0D%0A
 %0D%0A  
@@ -571,38 +571,95 @@
 %0D%0A%0D%0A        
+  
 if (
-isIndex)%0D%0A
+stat.isDirectory())%0D%0A          %7B%0D%0A            isIndex = true;%0D%0A  
           fi
@@ -683,18 +683,20 @@
 html';%0D%0A
-%0D%0A
+    
         
@@ -691,32 +691,33 @@
             if (
+!
 fs.existsSync(fi
@@ -726,33 +726,174 @@
 name))%0D%0A        
-%7B
+    %7B%0D%0A              res.writeHead(404);%0D%0A              res.end(filename + ' not found');%0D%0A              return;%0D%0A            %7D%0D%0A          %7D%0D%0A
 %0D%0A          var 

fix crash acp server on requests for unexists files