This is my project folder structure:
XYZ_PROJECT_FOLDER
ASSETS
CSS
IMAGES
JS
VENDOR
CONTACT.html
INDEX.html
INDEX.js
And this is the code inside the INDEX.js file to render all the static files and other routing code:
const express = require("express");
const nodemailer = require("nodemailer");
const multiparty = require("multiparty");
require("dotenv").config();
const app = express();
app.use(express.static('assets'));
app.route("/").get(function (req,res){
res.sendFile(process.cwd()+"/index.html")
})
app.route("/contact").get(function (req,res){
res.sendFile(process.cwd()+"/contact-form.html")
})
const PORT = process.env.PORT || 5000;
app.listen(PORT, () => {
console.log(`Listening on port ${PORT}...`);
});
Whenever I run the command "node INDEX.js" it works all fine but it is not rendering any css, image, or js scripts any leads would be appreciated.