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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
var http = require('http');
var ejs = require('ejs');
var express=require('express');
//The url we want is `www.nodejitsu.com:1337/`
var options = {
host: '192.168.1.154',
path: '/',
//since we are listening on a custom port, we need to specify it by hand
port: '5260',
//This is what changes the request to a POST request
method: 'POST'
};
callback = function(response) {
var str = ''
response.on('data', function (chunk) {
str += chunk;
});
response.on('end', function () {
console.log(str);
});
}
var app = express();
app.engine('html', ejs.renderFile);
app.set('/', __dirname);
app.get('/', function(request,response) {
response.render('index.ejs.html')
})
var res = http.request(options, callback);
res.write("START_BG;BG1\n");
app.listen(8080); |
Partager