Created
January 14, 2016 09:30
-
-
Save iuliaL/d55e37c61d5402748bf3 to your computer and use it in GitHub Desktop.
node http.createServer
This file contains 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
// 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