-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmlApp.js
36 lines (23 loc) · 808 Bytes
/
mlApp.js
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
/* global __dirname */
var http = require('http');
var portfinder = require('portfinder');
var ml = require('machine_learning');
// Code to include external javascript files.
var fs = require('fs');
var vm = require('vm');
var includeInThisContext = function(path) {
var code = fs.readFileSync(path);
vm.runInThisContext(code, path);
}.bind(this);
// Include javascript files.
includeInThisContext(__dirname+"/machinelearning.js");
portfinder.getPort(function (err, port) {
console.log( 'Port open:' + port);
http.createServer(function (req, res) {
// Response
res.writeHead(200, {'Content-Type': 'text/plain'});
var output = decisionTreeTest();
res.end( output );
}).listen( port, '127.0.0.1' );
console.log('Server running at http://127.0.0.1:' + port + '/' );
});