title: Returning a page through HTTP with express
body: <p>I have a folder called "Public" which contains an index.html file a long with some JavaScript and library files. When someone tries to access the products path (mydomain.com/products) I want to display that index.html file, but the client also needs to receive all the JavaScript and libraries. Here is the code for how I initially handle the HTTP request. </p>
  
  <pre><code>const express = require('express')
  const app = express()
  const bodyParse = require('body-parser')
  
  const productRoutes = require('./api/routes/products')
  const orderRoutes = require('./api/routes/orders')
  
  app.use(bodyParse.urlencoded({extended: false}))
  app.use(bodyParse.json())
  
  // Routes which handle requests
  app.use('/products', productRoutes)
  app.use('/orders', orderRoutes)
  </code></pre>
  
  <p>In the products.js file, I continue the routing like this:</p>
  
  <pre><code>const express = require('express')
  const router = express.Router()
  
  router.get('/', (req, res, next) =&gt; {
      /*res.status(200).json({
          message: 'Handling GET requests to /products'
      })*/
      res.status(200).render("../../public")
  })
  </code></pre>
  
  <p>The code I've commented out works perfectly fine, but I'm struggling to respond with the "public" folder page. I can't remember everything I've tried, but using .render or .sendFile on the "public" directory has not worked for me.</p>
  
  <p>When I try to access the /products route, I'm hit with an empty error message. As it fails to return anything in the /products route, in continues down the file to an error handler. The error message is empty.</p>
  
  <p>Any ideas on how to display the page with all the folder contents would be great!</p>