-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathserver.js
executable file
·53 lines (41 loc) · 1.23 KB
/
server.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env node
var express = require('express'),
fs = require('fs'),
completecdnfinder = require("./lib/cdnfinder.js").completecdnfinder,
hostnamefinder = require("./lib/hostnamefinder.js").hostnamefinder;
var app = express.createServer();
app.use(express.bodyParser());
app.post('/', function(req, res){
console.log(new Date(), req.connection.remoteAddress)
console.log(new Date(), req.body.url)
completecdnfinder(req.body.url, function(err, results){
if(results){
res.send(results);
} else {
res.send({"status": "FAILURE"});
}
});
});
app.post('/hostname/', function(req, res){
console.log(new Date(), req.connection.remoteAddress)
console.log(new Date(), req.body.hostname);
hostnamefinder(req.body.hostname, function(response){
res.send(response);
})
});
app.get('/', function(req, res){
console.log(new Date(), req.connection.remoteAddress)
fs.readFile(__dirname + '/lib/cdnfinder.html',
function (err, data) {
if (err) {
res.writeHead(500);
return res.end('Error loading cdnfinder.html');
}
res.writeHead(200);
res.end(data);
});
});
app.listen(1337);
//completecdnfinder("http://www.msnbc.com/", function(err, results){
// console.dir(results);
//});