Created
June 12, 2012 15:45
-
-
Save tanabe/2918306 to your computer and use it in GitHub Desktop.
phantom.js webserver
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
var server = require('webserver').create(); | |
var service = server.listen(9876, function (request, response) { | |
var fs = require('fs'); | |
var file = fs.read(fs.workingDirectory + request.url); | |
response.statusCode = 200; | |
response.headers['Content-Type'] = 'text/html'; | |
response.write(file); | |
response.close(); | |
}); | |
var page = require('webpage').create(); | |
page.onConsoleMessage = function(message) { | |
console.log(message); | |
}; | |
page.open('http://localhost:9876/aaa.html', function(status) { | |
page.evaluate(function() { | |
console.log(location.href); | |
}); | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment