Created
March 9, 2016 23:24
-
-
Save leosilvadev/cc73a583ea2620a4b815 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
var http = require('http'); | |
var server = http.createServer(function (request, response) { | |
var message; | |
var status; | |
if ( request.url === '/hello' ) { | |
message = 'Hello!'; | |
status = 200; | |
} else if ( request.url === '/ola' ) { | |
message = 'Ola!'; | |
status = 201; | |
} else { | |
status = 404; | |
message = 'Nada encontrado...'; | |
} | |
response.writeHead(status, {"Content-Type": "application/json"}); | |
response.end(JSON.stringify({message:message})); | |
}); | |
server.listen(8000, function(){ | |
console.log('Applicação rodando...') | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment