Skip to content

Instantly share code, notes, and snippets.

@iuliaL
Created January 14, 2016 09:30
Show Gist options
  • Save iuliaL/d55e37c61d5402748bf3 to your computer and use it in GitHub Desktop.
Save iuliaL/d55e37c61d5402748bf3 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