const express = require("express");
const app = express();
app.use(express.static("public"));
var dirname = __dirname;
app.get("/:lang/:app",function(req,res){
console.log(req.params.lang + " " + req.params.app);
res.sendFile(dirname + "/index.html", { layout: false });
});
app.listen(process.env.PORT || 3001,function(){
console.log("started");
});
I have encountered an issue with my index.js code. When I try to access a specific route like "/:lang/:app", the HTML and CSS files do not load properly and I receive the following error message: Error: ENOENT: no such file or directory, stat 'C:\Users\directory\calculator-release\index.html'. Can anyone help me fix this problem?
const express = require("express");
const app = express();
app.use(express.static("public"));
var dirname = __dirname;
app.get("/",function(req,res){
//console.log(req.params.lang + " " + req.params.app);
res.sendFile(dirname + "/index.html", { layout: false });
});
app.listen(process.env.PORT || 3001,function(){
console.log("started");
});
This revised code should work without any issues.