-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
40 lines (36 loc) · 982 Bytes
/
main.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
37
38
39
var http = require('http');
var botrecive = require('./botlookup.js');
var botsend = require('./botsend.js');
var async = require('async');
var postHTML =
'<html><head><title>Post Example</title></head>' +
'<body>' +
'<form method="post">' +
'Input 1: <input name="input1"><br>' +
//'Input 2: <input name="input2"><br>' +
'<input type="submit">' +
'</form>' +
'</body></html>';
http.createServer(function (req, res) {
var postData = "";
req.on('data', function (chunk) {
postData += chunk;
});
req.on('end' , function () {
var stringreturn = "";
async.series([
function(callback){
var result = botrecive.stringlookup(postData);
//console.log('Data Sent: ' + stringreturn);
callback(null, result);
}], function(err, result) {
console.log(result);
if(result != ""){
botsend.botresponder(result);
}
});
//console.log('POSTed: ' + postData);
res.writeHead(200);
//res.end(postHTML);
});
}).listen(8080);