var express = require('express');
var bodyParser = require('body-parser');
var exec = require('child_process').exec;

var User = require('./user');




var app = express();

app.use(bodyParser.json()); // for parsing application/json
app.use(bodyParser.urlencoded({ extended: true })); // for parsing application/x-www-form-urlencoded

app.use(function(req, res, next) {
	console.log(JSON.stringify(req.body));//post params...
	console.log(JSON.stringify(req.params));//path params...
	console.log(JSON.stringify(req.query));//query params...
	
	res.header("Access-Control-Allow-Origin", "*");
	res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, Token");
	next();
});

app.get('/', function (req, res) {
	res.send('Hello World!!!');
});



var server = app.listen(3000, function () {

	var host = server.address().address;
	var port = server.address().port;

	console.log('Example app listening at http://%s:%s', host, port);

});



/*
 * Deploy
 * 
 */
app.post('/do/deploy' , function(req,res){
	console.log("POST /do/deploy");
	res.writeHead(200, {'Content-Type' : 'text/plain'});
	res.end('post deploy test 02');
	
	exec('sudo ./../kcii_deploy.do',
	  function (error, stdout, stderr) {
	    console.log('stdout: ' + stdout);
	    console.log('stderr: ' + stderr);
	    if (error !== null) {
	      console.log('exec error: ' + error);
	    }
	});	
});

@@ -115,40 +115,8 @@
 c;%0A%0A
-var User = require('./user');%0A%0A%0A
 %0A%0Ava
@@ -134,17 +134,16 @@
 ress();%0A
-%0A
 app.use(
@@ -295,17 +295,16 @@
 encoded%0A
-%0A
 app.use(
@@ -673,79 +673,10 @@
 );%0A%0A
-app.get('/', function (req, res) %7B%0A%09res.send('Hello World!!!');%0A%7D);%0A
 %0A%0A
-%0A
 var 
@@ -865,16 +865,87 @@
 %0A%7D);%0A%0A%0A%0A
+app.get('/', function (req, res) %7B%0A%09res.send('Hello World!!!');%0A%7D);%0A%0A%0A%0A
 /*%0A * De

Test - remove user module.