# Serve an HTML page using Node.js

> Learn how to serve an index.html page using Node.js with no dependencies, using the http module and piping fs.createReadStream() to the response.

Author: [Flavio Copes](https://flaviocopes.com/about/) | Published: 2020-08-16 | Topics: [Node.js](https://flaviocopes.com/tags/node/) | Canonical: https://flaviocopes.com/node-serve-html-page/

I had the need to serve an HTML page from a [Node.js](https://flaviocopes.com/nodejs/) server, and this is the simplest code that does the trick:

```js
const http = require('http')
const fs = require('fs')

const server = http.createServer((req, res) => {
  res.writeHead(200, { 'content-type': 'text/html' })
  fs.createReadStream('index.html').pipe(res)
})

server.listen(process.env.PORT || 3000)
```

No dependencies needed.

Add this to an `app.js` file, then create an `index.html` page, and run `node app.js`

Notice that the above code does not provide support for serving static assets, it will just serve the `index.html` page.
