How to write ‘Beautiful Life’ in Node.js ?
Last Updated :
31 Mar, 2023
Node.js is an open-source and cross-platform runtime environment for executing JavaScript code outside a browser. You need to remember that NodeJS is not a framework and it’s not a programming language. Most people are confused and understand it’s a framework or a programming language. We often use Node.js for building back-end services like APIs like Web App or Mobile App. It’s used in production by large companies such as Paypal, Uber, Netflix, Walmart, and so on.
Example: In this article, we will learn how to write “Beautiful Life” in Node.js. Create a .js file like we have created the geeksforgeeks.js file and write down the following code in it.
Filename: geeksforgeeks.js
Javascript
const http = require( 'http' );
http.createServer( function (request, response) {
response.write( 'Beautiful Life' );
response.end();
}).listen(8080);
|
Step to run file: Open CMD and go to the folder directory where the above file is kept, then run the following command.
node geeksforgeeks.js
Output: Open any browser and go to http://localhost:8080/, you will see the following output.
Share your thoughts in the comments
Please Login to comment...