1

I was able to show the home page in this case index.html, but the page that I want open like a link not be displayed. Here's my code when i show the index.html:

app.get('/', function(req, res){
     res.sendFile(path.join(__dirname+'/public/index.html'));
 });

A body of index.html:

<body>
  <div style="margin:100px;">
    <nav class="navbar navbar-inverse navbar-static-top">
  <div class="container">
    <a class="navbar-brand" href="/">Express HTML</a>
    <ul class="nav navbar-nav">
      <li class="active">
        <a href="/">Home</a>
      </li>
      <li>
        <a href="../app/public/signup.html">Signup</a>
      </li>
      <li>
        <a href="../app/public/login.html">Login</a>
      </li>
    </ul>
  </div>
</nav>
  </div>
</body>

A problem is that i try a lot of ways to show singup.html and login.html and it's not working. If anyone has a solution?Thanks!

1 Answer 1

3

You are using path.join slightly incorrectly; path.join takes three parameters, not a singular 'pre-joined' parameter.

res.sendFile(path.join(__dirname+'/public/index.html'));

Should be:

res.sendFile(path.join(__dirname, '/public', 'index.html'));

Alternately, you could just skip the join entirely:

res.sendFile( __dirname + "/public/" + "index.html" );

Hope this helps!

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

1 Comment

Thanks for the help, but that didn't solve my problem. The problem is that I want to show signup.html and login.html pages, which are supposed to be opened by clicking on the 2 buttons on index.html page. It doesn't work tho, like the path is not correct.

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.