Skip to content

Instantly share code, notes, and snippets.

@anak10thn
Created August 7, 2013 14:11
Show Gist options
  • Save anak10thn/6174411 to your computer and use it in GitHub Desktop.
Save anak10thn/6174411 to your computer and use it in GitHub Desktop.
#!/usr/bin/env phantomjs
function load_page(req,res){
var path = req.url;
var read;
if(path == "/"){
read = fs.read('./app/index.html');
}
else {
if(fs.exists("./app"+path)){
read = fs.read("./app"+path);
}
}
res.write(read);
}
var server = require('webserver').create();
var fs = require('fs');
var service = server.listen(7777,function(req,res){
console.log(req.url);
res.statusCode = 200;
load_page(req,res);
res.close();
});
if(service){
console.log("Application running on port 7777");
}
else{
console.log("Error!!!");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment