Skip to content

Instantly share code, notes, and snippets.

@leosilvadev
Created March 9, 2016 23:24
Show Gist options
  • Save leosilvadev/cc73a583ea2620a4b815 to your computer and use it in GitHub Desktop.
Save leosilvadev/cc73a583ea2620a4b815 to your computer and use it in GitHub Desktop.
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