Created
January 28, 2019 14:20
-
-
Save brunopgalvao/360156ac3d610fdc1845f8a8e5af7489 to your computer and use it in GitHub Desktop.
a server using node and http module
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
// 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