Reputation: 129
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!
Upvotes: 1
Views: 5649
Reputation: 42304
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!
Upvotes: 3