if u meant the server.js...here is the code:
`const express = require('express');
const fs = require('fs');
const path = require('path');
const fileUpload = require('express-fileupload');
const app = express();
const PORT = process.env.PORT || 3000;
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.use(express.static('./public'));
app.use(fileUpload());
// Reading Data to JSON
app.get('/', (req, res) => {
res.sendFile(path.join(__dirname, './public/dashboard.html'));
});
// POST-Req. - Adding Data
app.post('/add-product', (req, res) => {
const newProduct = req.body; // New Product info - Formular
// Reading Data - JSON-File
fs.readFile('./public/data/shoes.json', 'utf8', (err, data) => {
if (err) {
console.error('Error reading file:', err);
return res.status(500).send('Error reading file');
}
const products = JSON.parse(data); // Convert JSON to JavaScript-Object
products.shoes.push(newProduct); // Add the new product
// write the new into the JSON-File
fs.writeFile('./public/data/shoes.json', JSON.stringify(products, null, 2), 'utf8', (err) => {
if (err) {
console.error('Error writing file:', err);
return res.status(500).send('Error writing file');
}
// Successful msg
res.status(200).send('Product added successfully');
});
});
});
// Server stuff
app.listen(PORT, () => {
console.log(Server is running on port ${PORT});
});`