Skip to content

Instantly share code, notes, and snippets.

@brunopgalvao
Created January 28, 2019 14:20
Show Gist options
  • Save brunopgalvao/360156ac3d610fdc1845f8a8e5af7489 to your computer and use it in GitHub Desktop.
Save brunopgalvao/360156ac3d610fdc1845f8a8e5af7489 to your computer and use it in GitHub Desktop.
a server using node and http module
// Load HTTP module
const http = require("http");
// Create HTTP server and listen on port 8000 for requests
http.createServer(function(request, response) {
// Set the response HTTP header with HTTP status and Content type
response.writeHead(200, {'Content-Type': 'text/plain'});
// Send the response body "Hello World"
response.end('Hello World\n');
}).listen(8000);
// Print URL for accessing server
console.log('Server running at http://127.0.0.1:8000/');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment