Skip to content

Instantly share code, notes, and snippets.

@gld1982ltd
Forked from iuliaL/server.js
Created January 22, 2016 18:51
Show Gist options
  • Save gld1982ltd/5a7a8ad2533b25d15642 to your computer and use it in GitHub Desktop.
Save gld1982ltd/5a7a8ad2533b25d15642 to your computer and use it in GitHub Desktop.
node http.createServer
// node server instead of xampp ;
var http = require('http');
var fs = require('fs');
http.createServer(function (request, response) {
var filePath = '.' + request.url;
console.log(request.url);
fs.readFile(filePath, function(error, content) {
response.writeHead(200);
response.end(content, 'utf-8');
});
}).listen(8080,'127.0.0.1', function() {
console.log('Server running at http://localhost:8080');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment