Created
April 30, 2015 12:57
-
-
Save DrMartiner/39b72f15e7ef2c844db6 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
var server = require('webserver').create(); | |
var port = 9091; | |
var getPage = function(url, callback) { | |
var page = require('webpage').create(); | |
page.open(url, function() { | |
setTimeout(function() { | |
page.evaluate(function() { | |
$('meta[name=fragment], script').remove() | |
}); | |
callback(page.content); | |
page.close(); | |
}, 200); | |
}); | |
}; | |
server.listen(port, function(request, response) { | |
response.headers = { | |
'Content-Type': 'text/html' | |
}; | |
var regexp = /_escaped_fragment_=(.*)$/; | |
var fragment = request.url.match(regexp); | |
var url = 'http://vestfin.com/#!' + decodeURIComponent(fragment[1]); | |
getPage(url, function(content) { | |
response.statusCode = 200; | |
response.write(content); | |
response.close(); | |
}) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment