Created
August 7, 2013 14:11
-
-
Save anak10thn/6174411 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
#!/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