91-9990449935 0120-4256464 |
Node.js Web ModuleWhat is Web ServerWeb Server is a software program that handles HTTTP requests sent by HTTP clients like web browsers, and returns web pages in response to the clients. Web servers usually respond with html documents along with images, style sheets and scripts. Most of the web server support server side scripts using scripting language or redirect to application server which perform the specific task of getting data from database, perform complex logic etc. and then sends a result to the HTTP client through the Web server. Apache web server is one of the most commonly used web server. It is an open source project. Web Application ArchitectureA web application can be divided in 4 layers:
Creating Web Server using Node.jsNode.js provides http module which can be used to create either HTTP client of server. Create a js file named server.js having the following code: Next, create an html file named index.html having the following code in the same directory where you created server.js Now open the Node.js command prompt and run the following code: node server.js Open http://127.0.0.1:8081/index.htm in any browser and see the below result.
Next TopicNode.js Interview Questions
|