nino-github-example
Version:
Get a list of github user repos
39 lines (35 loc) • 1.13 kB
JavaScript
// Myble Chat Networks
// Version: 1.0
// Date: 18-7-2013
// Author: Nino Merdzanovic
// Website: http://www.myble.nl
var http = require('http');
var fs = require('fs');
console.log("Myble Chat Server V1.0 - Running");
var config = JSON.parse(fs.readFileSync("config.json"));
var host = config.host;
var port = config.port;
var MybleChat = http.createServer(function(request, response){
console.log("Received request:" + request.url);
fs.readFile("./" + request.url, function(error,data){
if (error) {
response.writeHeader(404, {'content-type': 'text/html'});
response.end("Sorry the page was not found.");
} else {
response.writeHead(200, {'content-type': 'text/html'});
response.end(data);
}
})
});
MybleChat.listen(port, host, function() {
console.log("Listening to: " + host + ":" + port);
});
fs.watchFile("config.json", function(){
config = JSON.parse(fs.readFileSync("config.json"));
host = config.host;
port = config.port;
MybleChat.close();
MybleChat.listen(port, host, function() {
console.log("Now listening to: " + host + ":" + port);
});
});