0

I have a NodeJS project setup. I want to integrate my static html pages into it. Where can I do it ?

Thank you !

2
  • Are you using some kind of library such as Express for rendering? I see you've tagged Jade, I figured it was a useful question; the approach and possible solutions will differ based on what you're working with. Commented Jun 17, 2016 at 18:37
  • Yes I'm using Express. Sorry to have not mentioned it earlier. Commented Jun 17, 2016 at 18:39

1 Answer 1

1

To expose static html, create a directory named "public" that lives next to your primary application file (app.js).

Assuming you are using the express framework, you can expose this directory by using the following code:

app.use(express.static(__dirname + "/public"));

where

var app = express();

Subsequently, any request to "/{something}" will attempt to resolve a route to a static file in your public directory, so if you had a file named {something} in that directory it would get served right up.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.