---
title: "Create and Run a html page in nodejs in Windows OS"  
description: "n this blog, I’m explaining how to create an html page in nodejs and run in browser.  1.Let's start with the server module. Create the fileserver.js"  
author: "Anonymous User"  
published: 2014-01-25  
updated: 2020-02-03  
canonical: https://www.mindstick.com/blog/637/create-and-run-a-html-page-in-nodejs-in-windows-os  
category: "single page app"  
tags: ["single page app"]  
reading_time: 1 minute  

---

# Create and Run a html page in nodejs in Windows OS

n this blog, I’m explaining how to create an html page in [nodejs](https://www.mindstick.com/blog/640/download-install-and-setup-environment-for-nodejs-in-windows-os-64-bit) and run in [browser](https://www.mindstick.com/blog/155254/which-is-the-best-internet-browser).\

1. Let's start with the server module. Create the file server.js in the root [directory](https://www.mindstick.com/forum/226/how-to-get-application-directory-using-c-sharp-csharp) of [your project](https://www.mindstick.com/forum/156583/best-way-to-link-bootstrap-file-in-your-project), and fill it with the following code:

```
var http = require('http'),    fs = require('fs');    fs.readFile('./index.html', function (err, html) {    if (err) {        throw err;    }    http.createServer(function (request, response) {        response.writeHeader(200, { "Content-Type": "text/html" });        response.write(html);        response.end();    }).listen(8888);});
```

2. Create a html page “index.html” write code

```
<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head>
    <title></title></head><body>    <center><h3>Hello World</h3></center></body></html>
```

1. Open [command](https://www.mindstick.com/blog/178/synchronous-and-asynchronous-command-execution-in-c-sharp-dot-net) prompt and go to your file location.

2. [Execute](https://www.mindstick.com/interview/49/how-can-i-execute-a-php-script-using-command-line) your server.js file like this![Create and Run a html page in nodejs in Windows OS](https://www.mindstick.com/blogs/16704c44-7e2a-4117-ae9e-a1c50073ef5e/images/b56d4c4a-b091-4a61-a6b8-f6ba424b386b.png)\

Now start your server…

1. Now, open your browser and point it at http://localhost:8888/. This should display a [web page](https://www.mindstick.com/forum/718/sql-server-report-alignment-to-center-of-web-page) that says "[Hello World](https://www.mindstick.com/forum/12912/how-to-show-hello-world-backbone-marionette-js)".

Output

![Create and Run a html page in nodejs in Windows OS](https://www.mindstick.com/blogs/16704c44-7e2a-4117-ae9e-a1c50073ef5e/images/9af34494-5108-4519-88c9-971e1f034468.png)

\

in my next post i'll [explain](https://www.mindstick.com/forum/157854/what-is-system-debugging-explain-some-system-debugging-tools-used-in-modern-computer-systems) about [Angular JS](https://www.mindstick.com/blog/638/Angular%20JS)

---

Original Source: https://www.mindstick.com/blog/637/create-and-run-a-html-page-in-nodejs-in-windows-os

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
