I am creating nodeJS app. I am having index.html in which other HTML files (notes.html, to-do.html, etc.) are linked with but these are not working its giving error :
Cannot GET /to-do.html
My other HTML files are simply blank files with little text for now but I will be editing them. The main issue is that I am unable to load these pages, what should I do now.
index.html File :
<nav class="navbar navbar-expand-lg navbar-dark">
<div class="collapse navbar-collapse" id="nav-dropdown">
<ul class="navbar-nav ms-right">
<li class="nav-item">
<a href="/to-do.html" class="nav-link">To-Do</a>
</li>
</ul>
</div>
</nav>
My node.js file
//jshint esversion: 6
const express = require("express");
const path=require('path');
const https = require('https');
const app = express();
app.use(express.static(path.join(__dirname,"/public")));
app.get("/", function (req, res) {
res.sendFile(__dirname + "/index.html");
});
app.get("/toDo", function (req, res) {
res.sendFile(__dirname + "/to-do.html");
});
app.get("/notes", function (req, res) {
res.sendFile(__dirname + "/notes.html");
});
app.get("/currentAffairs", function (req, res) {
res.sendFile(__dirname + "/currentAffairs.html");
});
app.listen(3000,function(){
console.log("Server started on port 3000");
});
Aucun commentaire:
Enregistrer un commentaire